Skip to content

Conversation

@jborlase-snowplow
Copy link
Contributor

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.

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.
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 changed the base branch from master to release/4.6.4 May 29, 2025 19:53
Copy link
Contributor

@matus-tomlein matus-tomlein left a 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.

@matus-tomlein matus-tomlein requested a review from igneel64 May 29, 2025 20:00
jborlase-snowplow and others added 2 commits May 30, 2025 12:27
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 greg-el self-requested a review June 23, 2025 13:32
Copy link
Contributor

@greg-el greg-el left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! LGTM!

@greg-el greg-el merged commit 90c9639 into snowplow:release/4.6.4 Jun 23, 2025
1 check failed
greg-el pushed a commit that referenced this pull request Jun 23, 2025
Fixing GA4 Add To Cart for GTM Ecommerce Template
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.
@greg-el greg-el mentioned this pull request Jun 24, 2025
greg-el pushed a commit that referenced this pull request Jun 25, 2025
Fixing GA4 Add To Cart for GTM Ecommerce Template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants