From 040f93f65e6a11ba7be9d0933a4e5751e3a9cb3b Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Mon, 4 Mar 2024 17:15:50 +0200 Subject: [PATCH 1/8] fix name of 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 87c9fe6bae..8a766d1821 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -15,8 +15,8 @@ const ProvisionsPopup = () => { ); const gtmEvent = (event: string) => window?.dataLayer.push({ event }); - const gtmEventClickReadMore = () => gtmEvent("Provisions popup click"); - const gtmEventClickClose = () => gtmEvent("Provisions popup close"); + const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); + const gtmEventClickClose = () => gtmEvent("Provisions_popup_close"); const onClose = (event: React.MouseEvent) => { event.stopPropagation(); From aa622b44072dc4a425ccb489f4089909b1d0cc67 Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 10:22:09 +0200 Subject: [PATCH 2/8] trying to add provisions under click event --- .../components/ProvisionsPopup/ProvisionsPopup.tsx | 11 ++++++++--- .../website/src/renderer/_default.page.server.tsx | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 8a766d1821..13d043c82f 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -14,9 +14,14 @@ 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 = (event: string) => + window?.dataLayer.push({ + event: "click", + popup: "provisions", + interaction: event, + }); + const gtmEventClickReadMore = () => gtmEvent("Read_More"); + const gtmEventClickClose = () => gtmEvent("Dismiss"); const onClose = (event: React.MouseEvent) => { event.stopPropagation(); diff --git a/workspaces/website/src/renderer/_default.page.server.tsx b/workspaces/website/src/renderer/_default.page.server.tsx index 8a16c7c072..6849421607 100644 --- a/workspaces/website/src/renderer/_default.page.server.tsx +++ b/workspaces/website/src/renderer/_default.page.server.tsx @@ -21,6 +21,7 @@ declare global { interface Window { dataLayer: { event: string; + [k: string]: string; }[]; } } From e150b59d253ec996b2a8ea4776fe0a8e43c8c54e Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 10:59:32 +0200 Subject: [PATCH 3/8] check gtag instead of dataLayer --- .../components/ProvisionsPopup/ProvisionsPopup.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 13d043c82f..eb7e8ccc1b 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -14,14 +14,9 @@ const ProvisionsPopup = () => { !isSsr ); - const gtmEvent = (event: string) => - window?.dataLayer.push({ - event: "click", - popup: "provisions", - interaction: event, - }); - const gtmEventClickReadMore = () => gtmEvent("Read_More"); - const gtmEventClickClose = () => gtmEvent("Dismiss"); + const gtmEvent = (event: string) => window.gtag?.(event); + const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); + const gtmEventClickClose = () => gtmEvent("Provisions_popup_close"); const onClose = (event: React.MouseEvent) => { event.stopPropagation(); From e30bb930ea8392e9e9511e4fb4513c4b40681603 Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 11:18:10 +0200 Subject: [PATCH 4/8] change back --- .../website/src/components/ProvisionsPopup/ProvisionsPopup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index eb7e8ccc1b..8a766d1821 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -14,7 +14,7 @@ const ProvisionsPopup = () => { !isSsr ); - const gtmEvent = (event: string) => window.gtag?.(event); + const gtmEvent = (event: string) => window?.dataLayer.push({ event }); const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); const gtmEventClickClose = () => gtmEvent("Provisions_popup_close"); From 765772621cfe1d6c17fab0aa80be17f252f6f437 Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 11:47:29 +0200 Subject: [PATCH 5/8] testing changes --- .../src/components/ProvisionsPopup/ProvisionsPopup.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 8a766d1821..292ef4fa81 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -13,6 +13,8 @@ const ProvisionsPopup = () => { "isProvisionsPopupOpen", !isSsr ); + const click = (target: string) => + window?.dataLayer.push({ event: "click", target }); const gtmEvent = (event: string) => window?.dataLayer.push({ event }); const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); @@ -21,12 +23,14 @@ const ProvisionsPopup = () => { const onClose = (event: React.MouseEvent) => { event.stopPropagation(); gtmEventClickClose(); + click("Provisions_popup_close"); setIsOpenStorage(false); }; const onReadMore = (event: React.MouseEvent) => { event.stopPropagation(); gtmEventClickReadMore(); + click("Provisions_popup_click"); setIsOpenStorage(false); }; From eba65f8cd77dcef610c1b54b9c3dac77aa8c5134 Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 11:55:02 +0200 Subject: [PATCH 6/8] change event to page view --- .../src/components/ProvisionsPopup/ProvisionsPopup.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 292ef4fa81..fa60391e82 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -13,8 +13,8 @@ const ProvisionsPopup = () => { "isProvisionsPopupOpen", !isSsr ); - const click = (target: string) => - window?.dataLayer.push({ event: "click", target }); + const pageView = (target: string) => + window?.dataLayer.push({ event: "page_view", target }); const gtmEvent = (event: string) => window?.dataLayer.push({ event }); const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); @@ -23,14 +23,14 @@ const ProvisionsPopup = () => { const onClose = (event: React.MouseEvent) => { event.stopPropagation(); gtmEventClickClose(); - click("Provisions_popup_close"); + pageView("Provisions_popup_close"); setIsOpenStorage(false); }; const onReadMore = (event: React.MouseEvent) => { event.stopPropagation(); gtmEventClickReadMore(); - click("Provisions_popup_click"); + pageView("Provisions_popup_click"); setIsOpenStorage(false); }; From ecba8f6bc0a4223dd074101413f6863af1a9402f Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 14:08:13 +0200 Subject: [PATCH 7/8] fixing issue --- .../src/components/ProvisionsPopup/ProvisionsPopup.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index fa60391e82..0cc835744d 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -14,7 +14,9 @@ const ProvisionsPopup = () => { !isSsr ); const pageView = (target: string) => - window?.dataLayer.push({ event: "page_view", target }); + window.gtag("event", target, { + event_category: "engagement", + }); const gtmEvent = (event: string) => window?.dataLayer.push({ event }); const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); From be35b3c3167d57b51d40dd93870faf24a9fb8e0e Mon Sep 17 00:00:00 2001 From: Tal-Ben-Avi Date: Tue, 5 Mar 2024 14:24:54 +0200 Subject: [PATCH 8/8] commit changes --- .../components/ProvisionsPopup/ProvisionsPopup.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx index 0cc835744d..9b5d78501c 100644 --- a/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx +++ b/workspaces/website/src/components/ProvisionsPopup/ProvisionsPopup.tsx @@ -13,26 +13,21 @@ const ProvisionsPopup = () => { "isProvisionsPopupOpen", !isSsr ); - const pageView = (target: string) => + const gtmEvent = (target: string) => window.gtag("event", target, { event_category: "engagement", }); - const gtmEvent = (event: string) => window?.dataLayer.push({ event }); - const gtmEventClickReadMore = () => gtmEvent("Provisions_popup_click"); - const gtmEventClickClose = () => gtmEvent("Provisions_popup_close"); - const onClose = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEventClickClose(); - pageView("Provisions_popup_close"); + gtmEvent("Provisions_popup_close"); setIsOpenStorage(false); }; const onReadMore = (event: React.MouseEvent) => { event.stopPropagation(); - gtmEventClickReadMore(); - pageView("Provisions_popup_click"); + gtmEvent("Provisions_popup_click"); + gtmEvent("sample_event"); setIsOpenStorage(false); };