Skip to content
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

Google Tag Manager: Send through Tier1/2/3/OneTime products for trigger identification #6428

Merged
merged 7 commits into from
Oct 22, 2024
6 changes: 4 additions & 2 deletions support-frontend/assets/helpers/tracking/googleTagManager.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,7 +20,7 @@ type ContributionConversionData = {
contributionType: ContributionType;
currency: IsoCurrency;
paymentMethod: PaymentMethod;
productType: 'Contribution';
productType: ProductKey;
};

type SubscriptionConversionData = {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,15 @@ export function ThankYouComponent({
: order.paymentMethod;

successfulContributionConversion(
payment.originalAmount,
payment.finalAmount, // This is the final amount after discounts
paul-daniel-dempsey marked this conversation as resolved.
Show resolved Hide resolved
contributionType,
currencyKey,
paymentMethod,
productKey ?? 'Contribution', // One-off is labelled Contribution in Tag Manager
);
// track conversion with QM
sendEventContributionCheckoutConversion(
payment.originalAmount,
payment.originalAmount, // This is the amount before discounts
paul-daniel-dempsey marked this conversation as resolved.
Show resolved Hide resolved
contributionType,
currencyKey,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export function SupporterPlusThankYou({
contributionType,
currencyId,
paymentMethod,
isSupporterPlus ? 'SupporterPlus' : 'Contribution',
paul-daniel-dempsey marked this conversation as resolved.
Show resolved Hide resolved
);
// track conversion with QM
sendEventContributionCheckoutConversion(
Expand Down