From 974620687f195bf1266841688a103c79d4b123fb Mon Sep 17 00:00:00 2001 From: jaaaaavier Date: Thu, 16 Jan 2025 09:18:22 +0100 Subject: [PATCH] feat: add Google Ads conversion tracking for payment steps --- .../IntegratedCheckoutView/CheckoutView.tsx | 28 ++++++++----------- .../CheckoutViewWrapper.tsx | 4 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/app/payment/views/IntegratedCheckoutView/CheckoutView.tsx b/src/app/payment/views/IntegratedCheckoutView/CheckoutView.tsx index 826489838..6be292b28 100644 --- a/src/app/payment/views/IntegratedCheckoutView/CheckoutView.tsx +++ b/src/app/payment/views/IntegratedCheckoutView/CheckoutView.tsx @@ -15,7 +15,7 @@ import { LegacyRef } from 'react'; import { OptionalB2BDropdown } from 'app/payment/components/checkout/OptionalB2BDropdown'; import { UserType } from '@internxt/sdk/dist/drive/payments/types'; -const SEND_TO = process.env.REACT_APP_GOOGLE_ANALYTICS_SENDTO; +const SEND_TO = process.env.SEND_TO; export const PAYMENT_ELEMENT_OPTIONS: StripePaymentElementOptions = { wallets: { @@ -52,8 +52,6 @@ const CheckoutView = ({ checkoutViewManager, }: CheckoutViewProps) => { const { translate } = useTranslationContext(); - // Those custom hooks should be here. - // They cannot be moved to the Parent, because it must be wrapped by component. const stripeSDK = useStripe(); const elements = useElements(); @@ -113,21 +111,12 @@ const CheckoutView = ({ return false; } - const handleFormSubmit = (formData: IFormValues, event: any) => { - event.preventDefault(); - checkoutViewManager.onCheckoutButtonClicked(formData, event, stripeSDK, elements); - - if (authMethod === AUTH_METHOD_VALUES.IS_SIGNED_IN) { - gtag_report_conversion_step2('/checkout/success'); - } else { - gtag_report_conversion_create_account('/checkout/success'); - } - }; - return (
+ checkoutViewManager.onCheckoutButtonClicked(formData, event, stripeSDK, elements), + )} >
@@ -175,7 +164,13 @@ const CheckoutView = ({ {error.stripe}
)} - diff --git a/src/app/payment/views/IntegratedCheckoutView/CheckoutViewWrapper.tsx b/src/app/payment/views/IntegratedCheckoutView/CheckoutViewWrapper.tsx index d9c5f33f1..dd93a67e7 100644 --- a/src/app/payment/views/IntegratedCheckoutView/CheckoutViewWrapper.tsx +++ b/src/app/payment/views/IntegratedCheckoutView/CheckoutViewWrapper.tsx @@ -31,7 +31,7 @@ import ChangePlanDialog from '../../../newSettings/Sections/Account/Plans/compon import { getProductAmount } from 'app/payment/utils/getProductAmount'; import { bytesToString } from 'app/drive/services/size.service'; -const SEND_TO = process.env.REACT_APP_GOOGLE_ANALYTICS_SENDTO; +const SEND_TO = process.env.GOOGLE_ANALYTICS_SENDTO; export const THEME_STYLES = { dark: { @@ -312,7 +312,7 @@ const CheckoutViewWrapper = () => { const handlePaymentSuccess = () => { if (window && window.gtag) { window.gtag('event', 'conversion', { - send_to: SEND_TO, + send_to: 'AW-728922855/qLXECNiH2YcaEOf1ydsC', value: 1.0, currency: 'EUR', transaction_id: localStorageService.get('subscriptionId') || '',