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) {