From 09c6eded12eebdec22d8f1a849a1df74ebfbbc57 Mon Sep 17 00:00:00 2001 From: Precious Onyenaucheya Date: Tue, 31 Oct 2023 14:57:17 +0000 Subject: [PATCH] update analytics.js file --- src/js/analytics.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/js/analytics.js b/src/js/analytics.js index 7ac9924065..ce9b3bdb79 100644 --- a/src/js/analytics.js +++ b/src/js/analytics.js @@ -5,18 +5,17 @@ export let trackEvent = (event, data) => { console.log(data); // eslint-disable-line no-console }; -if (typeof window.ga !== 'undefined') { +if (typeof window.gtag !== 'undefined') { trackEvent = (evt, data) => { - window.ga(evt, data); + window.gtag('event', evt, data); }; } export const trackElement = (el) => { return trackEvent('send', { - hitType: 'event', - eventCategory: el.getAttribute('data-ga-category') || '', - eventAction: el.getAttribute('data-ga-action') || '', - eventLabel: el.getAttribute('data-ga-label') || '', + event_category: el.getAttribute('data-ga-category') || '', + event_action: el.getAttribute('data-ga-action') || '', + event_label: el.getAttribute('data-ga-label') || '', }); }; @@ -42,10 +41,9 @@ export default function initAnalytics() { const afterPrint = () => { return trackEvent('send', { - hitType: 'event', - eventCategory: 'Print Intent', - eventAction: 'Print Intent', - eventLabel: window.location.pathname.split('/').slice(-3).join('/'), + event_category: 'Print Intent', + event_action: 'Print Intent', + event_label: window.location.pathname.split('/').slice(-3).join('/'), }); };