From ab35d72d65501251f579adf210051e2847cad41b Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 18 Nov 2024 10:59:40 +0700 Subject: CR gtag user_data on page checkout --- src/lib/checkout/components/Checkout.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/lib/checkout') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index afbf1e6c..4c5cca62 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -37,6 +37,18 @@ const SELF_PICKUP_ID = 32; const { checkoutApi } = require('../api/checkoutApi'); const { getProductsCheckout } = require('../api/checkoutApi'); +function convertToInternational(number) { + if (typeof number !== 'string') { + throw new Error("Input harus berupa string"); + } + + if (number.startsWith('08')) { + return '+62' + number.slice(2); + } + + return number; +} + const Checkout = () => { const router = useRouter(); const query = router.query.source ?? null; @@ -491,7 +503,7 @@ const Checkout = () => { gtag('set', 'user_data', { email: auth.email, - phone_number: auth.mobile ?? auth.phone, + phone_number: convertToInternational(auth.mobile) ?? convertToInternational(auth.phone), }); for (const product of products) deleteItemCart({ productId: product.id }); -- cgit v1.2.3 From bde516b6b39cccfe8ac3248cd7f85592e6298d7a Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 18 Nov 2024 11:24:56 +0700 Subject: add google tag allow_enhanced_conversions --- src/lib/checkout/components/Checkout.jsx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/lib/checkout') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 4c5cca62..6fb5cdb4 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -506,6 +506,8 @@ const Checkout = () => { phone_number: convertToInternational(auth.mobile) ?? convertToInternational(auth.phone), }); + gtag('config', 'AW-954540379', { ' allow_enhanced_conversions':true } ) ; + for (const product of products) deleteItemCart({ productId: product.id }); if (grandTotal > 0) { const payment = await axios.post( -- cgit v1.2.3