Merge pull request #5442 from overleaf/ta-ga-v4

Add Google Analytics V4 Tags

GitOrigin-RevId: 8841bd6a902efa15399b1a219ff7740635898fa1
This commit is contained in:
Timothée Alby 2021-10-22 10:02:41 +02:00 committed by Copybot
parent 735f79ab6a
commit 9278ce6cc0
3 changed files with 21 additions and 0 deletions

View file

@ -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()
})

View file

@ -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

View file

@ -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