-
Notifications
You must be signed in to change notification settings - Fork 229
Fixing GA4 Add To Cart for GTM Ecommerce Template #1435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing GA4 Add To Cart for GTM Ecommerce Template #1435
Conversation
Per snowplow/snowplow-javascript-tracker#1435 the handling of `opts` parameter assumes both it and the `ecommerce` object will be checked for each option, but this is not the case in some cases (e.g. `finalCartValue`, `step`, `paymentMethod`). This corrects the interface selection so the parameters are passed correctly.
Per snowplow/snowplow-javascript-tracker#1435 the handling of `opts` parameter assumes both it and the `ecommerce` object will be checked for each option, but this is not the case in some cases (e.g. `finalCartValue`, `step`, `paymentMethod`). This corrects the interface selection so the parameters are passed correctly.
matus-tomlein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, @jborlase-snowplow! LGTM, but adding @igneel64 for a second pair of eyes as I don't have much experience with this use case.
Nice! I should really spend some time learning TypeScript. Co-authored-by: Matus Tomlein <matus.tomlein@gmail.com>
Including Matus' feedback Co-authored-by: Matus Tomlein <matus.tomlein@gmail.com>
greg-el
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! LGTM!
Fixing GA4 Add To Cart for GTM Ecommerce Template
Per snowplow/snowplow-javascript-tracker#1435 the handling of `opts` parameter assumes both it and the `ecommerce` object will be checked for each option, but this is not the case in some cases (e.g. `finalCartValue`, `step`, `paymentMethod`). This corrects the interface selection so the parameters are passed correctly.
Fixing GA4 Add To Cart for GTM Ecommerce Template
The current implementation of the trackGA4AddToCart is incompatible with the Snowplow Ecommerce tag template. The tag template combines the opts and ecommerce objects. There is no method to pass multiple parameters through the GTM template. The result is that the add to cart and remove to cart events are always invalid since they require a total_value property that comes from the finalCartValue.
This fix allows the JavaScript tracker to check the ecommerce object for the finalCartValue.