From 1fbf8dbec8e8931902d2379125bc57303d9f5dee Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 14:30:03 +0200 Subject: [PATCH 1/3] fixing provisions popup ga4 events --- .../components/ProvisionsPopup/ProvisionsPopup.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 87c9fe6bae..0fafeb5373 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -14,19 +14,20 @@ const ProvisionsPopup = () => { !isSsr ); - const gtmEvent = (event: string) => window?.dataLayer.push({ event }); - const gtmEventClickReadMore = () => gtmEvent("Provisions popup click"); - const gtmEventClickClose = () => gtmEvent("Provisions popup close"); + const gtmEvent = (target: string) => + window.gtag("event", target, { + event_category: "engagement", + }); const onClose = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEventClickClose(); + gtmEvent("Provisions popup click"); setIsOpenStorage(false); }; const onReadMore = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEventClickReadMore(); + gtmEvent("Provisions popup close"); setIsOpenStorage(false); }; From df5077c4ef80f385f969b859906bdbe87fcb187b Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 14:33:57 +0200 Subject: [PATCH 2/3] fix names events --- .../src/components/ProvisionsPopup/ProvisionsPopup.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 0fafeb5373..cb83281e34 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -21,13 +21,13 @@ const ProvisionsPopup = () => { const onClose = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEvent("Provisions popup click"); + gtmEvent("Provisions_popup_close"); setIsOpenStorage(false); }; const onReadMore = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEvent("Provisions popup close"); + gtmEvent("Provisions_popup_click"); setIsOpenStorage(false); }; From 32492d0c68fc955e9fbc21ba6447272872ddb9b8 Mon Sep 17 00:00:00 2001 From: Igal Steklov Date: Wed, 6 Mar 2024 14:13:28 +0000 Subject: [PATCH 3/3] Call `gtag` only if it is defined --- .../src/components/ProvisionsPopup/ProvisionsPopup.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index cb83281e34..d27cc88672 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -15,9 +15,7 @@ const ProvisionsPopup = () => { ); const gtmEvent = (target: string) => - window.gtag("event", target, { - event_category: "engagement", - }); + window.gtag?.("event", target, { event_category: "engagement" }); const onClose = (event: React.MouseEvent) => { event.stopPropagation();