diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 72c1380b3c..526a4cbd03 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -280,6 +280,10 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) { webRouter.use(function (req, res, next) { res.locals.gaToken = Settings.analytics && Settings.analytics.ga && Settings.analytics.ga.token + res.locals.gaTokenV4 = + Settings.analytics && + Settings.analytics.ga && + Settings.analytics.ga.tokenV4 res.locals.gaOptimizeId = _.get(Settings, ['analytics', 'gaOptimize', 'id']) next() }) diff --git a/services/web/app/views/layout-marketing.pug b/services/web/app/views/layout-marketing.pug index 356bd132da..23d5c6f56e 100644 --- a/services/web/app/views/layout-marketing.pug +++ b/services/web/app/views/layout-marketing.pug @@ -71,6 +71,14 @@ html( script(type="text/javascript", nonce=scriptNonce). window.ga = function() { console.log("would send to GA", arguments) }; + if (typeof(gaTokenV4) != "undefined") + script(async, nonce=scriptNonce, src='https://www.googletagmanager.com/gtag/js?id=' + gaTokenV4) + script(type="text/javascript", nonce=scriptNonce). + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', '#{gaTokenV4}'); + block meta meta(name="ol-csrfToken" content=csrfToken) //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index f9dae17e71..cffd0b58e7 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -68,6 +68,15 @@ html( script(type="text/javascript", nonce=scriptNonce). window.ga = function() { console.log("would send to GA", arguments) }; + if (typeof(gaTokenV4) != "undefined") + script(async, nonce=scriptNonce, src='https://www.googletagmanager.com/gtag/js?id=' + gaTokenV4) + script(type="text/javascript", nonce=scriptNonce). + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + + gtag('config', '#{gaTokenV4}'); + block meta meta(name="ol-csrfToken" content=csrfToken) //- Configure dynamically loaded assets (via webpack) to be downloaded from CDN