From 6d90bc9ecc07fd5849f716cb48709ffca4f53c7f Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Fri, 5 Apr 2024 08:11:29 -0400 Subject: [PATCH] fix: google tag manager --- src/analytics.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/analytics.js b/src/analytics.js index f47b53bfc..66eb1b636 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -1,14 +1,19 @@ if (process.env.GTM_ID) { - ;(function (w, d, s, l, i) { - w[l] = w[l] || [] - w[l].push({ 'gtm.start': new Date().getTime(), event: 'analytics.js' }) + ;(function (w, d, s, i) { var f = d.getElementsByTagName(s)[0] var j = d.createElement(s) - var dl = l !== 'dataLayer' ? '&l=' + l : '' j.async = true - j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl + j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i f.parentNode.insertBefore(j, f) - })(window, document, 'script', 'dataLayer', process.env.GTM_ID) + + w.dataLayer = w.dataLayer || [] + function gtag() { + w.dataLayer.push(arguments) + } + gtag('js', new Date()) + + gtag('config', i) + })(window, document, 'script', process.env.GTM_ID) } if (process.env.ADOBE_LAUNCH_SCRIPT_URL) { ;(function (w, d, s, i) {