Fixing GA4 Add To Cart for GTM Ecommerce Template#1435
Merged
Greg Leonard (greg-el) merged 4 commits intosnowplow:release/4.6.4from Jun 23, 2025
Merged
Fixing GA4 Add To Cart for GTM Ecommerce Template#1435Greg Leonard (greg-el) merged 4 commits intosnowplow:release/4.6.4from
Greg Leonard (greg-el) merged 4 commits intosnowplow:release/4.6.4from
Conversation
Jethro Nederhof (jethron)
added a commit
to snowplow/snowplow-gtm-tag-template-ecommerce-v3
that referenced
this pull request
May 29, 2025
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.
Jethro Nederhof (jethron)
added a commit
to snowplow/snowplow-gtm-tag-template-ecommerce-v3
that referenced
this pull request
May 29, 2025
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 (matus-tomlein)
approved these changes
May 29, 2025
Contributor
Matus Tomlein (matus-tomlein)
left a comment
There was a problem hiding this comment.
Thanks for the contribution, jborlase-snowplow! LGTM, but adding Peter Perlepes (@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 Leonard (greg-el)
approved these changes
Jun 23, 2025
Contributor
Greg Leonard (greg-el)
left a comment
There was a problem hiding this comment.
Nice one! LGTM!
90c9639
into
snowplow:release/4.6.4
1 check failed
Greg Leonard (greg-el)
pushed a commit
that referenced
this pull request
Jun 23, 2025
Fixing GA4 Add To Cart for GTM Ecommerce Template
Jethro Nederhof (jethron)
added a commit
to snowplow/snowplow-gtm-tag-template-ecommerce-v3
that referenced
this pull request
Jun 23, 2025
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.
Merged
Greg Leonard (greg-el)
pushed a commit
that referenced
this pull request
Jun 25, 2025
Fixing GA4 Add To Cart for GTM Ecommerce Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.