From bb4ca004f2e7aa80050869678f2dd9a4207a6bc4 Mon Sep 17 00:00:00 2001 From: Paul Dempsey <76729591+paul-daniel-dempsey@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:42:06 +0100 Subject: [PATCH 1/3] feat: productType sent to GoogleTagManager --- .../assets/helpers/tracking/googleTagManager.ts | 6 ++++-- .../assets/pages/[countryGroupId]/components/thankyou.tsx | 1 + .../supporter-plus-thank-you/supporterPlusThankYou.tsx | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/support-frontend/assets/helpers/tracking/googleTagManager.ts b/support-frontend/assets/helpers/tracking/googleTagManager.ts index 32ea7d4e99..1ec14453c6 100644 --- a/support-frontend/assets/helpers/tracking/googleTagManager.ts +++ b/support-frontend/assets/helpers/tracking/googleTagManager.ts @@ -1,6 +1,7 @@ import { v4 as uuidv4 } from 'uuid'; import type { ContributionType } from 'helpers/contributions'; import type { IsoCurrency } from 'helpers/internationalisation/currency'; +import type { ProductKey } from 'helpers/productCatalog'; import type { BillingPeriod } from 'helpers/productPrice/billingPeriods'; import type { SubscriptionProduct } from 'helpers/productPrice/subscriptions'; import * as storage from 'helpers/storage/storage'; @@ -19,7 +20,7 @@ type ContributionConversionData = { contributionType: ContributionType; currency: IsoCurrency; paymentMethod: PaymentMethod; - productType: 'Contribution'; + productType: ProductKey; }; type SubscriptionConversionData = { @@ -254,13 +255,14 @@ function successfulContributionConversion( contributionType: ContributionType, sourceCurrency: IsoCurrency, paymentMethod: PaymentMethod, + productKey: ProductKey, ): void { const contributionConversionData: ContributionConversionData = { value: amount, contributionType, currency: sourceCurrency, paymentMethod, - productType: 'Contribution', + productType: productKey, }; sendData('SuccessfulConversion', contributionConversionData); diff --git a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx index 7f2ad74916..51c444ef6e 100644 --- a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx @@ -154,6 +154,7 @@ export function ThankYouComponent({ contributionType, currencyKey, paymentMethod, + productKey ?? 'Contribution', // One-off is labelled Contribution in Tag Manager ); // track conversion with QM sendEventContributionCheckoutConversion( diff --git a/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx b/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx index 8afa423f71..24989078bc 100644 --- a/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx +++ b/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx @@ -190,6 +190,7 @@ export function SupporterPlusThankYou({ contributionType, currencyId, paymentMethod, + isSupporterPlus ? 'SupporterPlus' : 'Contribution', ); // track conversion with QM sendEventContributionCheckoutConversion( From 59eb80e7be034ae2049d2a5f6b85d2656534bb70 Mon Sep 17 00:00:00 2001 From: Paul Dempsey <76729591+paul-daniel-dempsey@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:17:21 +0100 Subject: [PATCH 2/3] feat: final amount paid (incl promoCode) passed to Google Tag Manager --- .../assets/pages/[countryGroupId]/components/thankyou.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx index 51c444ef6e..74ead4d06f 100644 --- a/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx +++ b/support-frontend/assets/pages/[countryGroupId]/components/thankyou.tsx @@ -150,7 +150,7 @@ export function ThankYouComponent({ : order.paymentMethod; successfulContributionConversion( - payment.originalAmount, + payment.finalAmount, // This is the final amount after discounts contributionType, currencyKey, paymentMethod, @@ -158,7 +158,7 @@ export function ThankYouComponent({ ); // track conversion with QM sendEventContributionCheckoutConversion( - payment.originalAmount, + payment.originalAmount, // This is the amount before discounts contributionType, currencyKey, ); From 01a600282085759abfad13a551303ea625cccf82 Mon Sep 17 00:00:00 2001 From: Paul Dempsey <76729591+paul-daniel-dempsey@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:01:12 +0100 Subject: [PATCH 3/3] review: S+ only GTM tracking for its own thankyou page --- .../pages/supporter-plus-thank-you/supporterPlusThankYou.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx b/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx index 24989078bc..abdb36ac71 100644 --- a/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx +++ b/support-frontend/assets/pages/supporter-plus-thank-you/supporterPlusThankYou.tsx @@ -190,7 +190,7 @@ export function SupporterPlusThankYou({ contributionType, currencyId, paymentMethod, - isSupporterPlus ? 'SupporterPlus' : 'Contribution', + 'SupporterPlus', ); // track conversion with QM sendEventContributionCheckoutConversion(