Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@snowplow/browser-plugin-snowplow-ecommerce",
"comment": "Fixing GA4 Ecommerce functions to use finalCartValue within ecommerce object",
"type": "none"
}
],
"packageName": "@snowplow/browser-plugin-snowplow-ecommerce"
}
10 changes: 6 additions & 4 deletions plugins/browser-plugin-snowplow-ecommerce/src/ga4/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ export function trackGA4SelectPromotion(ecommerce: GA4EcommerceObject & Promotio
}

export function trackGA4AddToCart(
ecommerce: GA4EcommerceObject & Currency,
ecommerce: GA4EcommerceObject & Currency & { finalCartValue?: number },
opts: Options & { finalCartValue: number }
) {
const currency = (ecommerce.currency || opts.currency)!;
const finalCartValue = ecommerce.finalCartValue ?? opts.finalCartValue;
const products = transformG4ItemsToSPProducts(ecommerce, currency);
trackAddToCart({ products, total_value: opts.finalCartValue, currency });
trackAddToCart({ products, total_value: finalCartValue, currency });
}

export function trackGA4RemoveFromCart(
ecommerce: GA4EcommerceObject & Currency,
ecommerce: GA4EcommerceObject & Currency & { finalCartValue?: number },
opts: Options & { finalCartValue: number }
) {
const currency = (ecommerce.currency || opts.currency)!;
const finalCartValue = ecommerce.finalCartValue ?? opts.finalCartValue;
const products = transformG4ItemsToSPProducts(ecommerce, currency);
trackRemoveFromCart({ products, total_value: opts.finalCartValue, currency });
trackRemoveFromCart({ products, total_value: finalCartValue, currency });
}

export function trackGA4ViewItem(ecommerce: GA4EcommerceObject, opts: Options = {}) {
Expand Down
Loading