From 954c62ec1da9e857118357c8a5f2bf92a572496e Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 5 Apr 2022 10:23:33 +0100 Subject: [PATCH] Merge pull request #7321 from overleaf/ta-ga-fallback Fix window-ga Fallback GitOrigin-RevId: 56b192acbae5c8ba23c63f6d4a7d7334d13b8c73 --- services/web/app/views/_google_analytics.pug | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/web/app/views/_google_analytics.pug b/services/web/app/views/_google_analytics.pug index 9b60144f97..1588da98ab 100644 --- a/services/web/app/views/_google_analytics.pug +++ b/services/web/app/views/_google_analytics.pug @@ -44,7 +44,10 @@ if (typeof(ExposedSettings.gaTokenV4) != "undefined" || typeof(ExposedSettings.g loadGA(); } } -else - script(type="text/javascript", nonce=scriptNonce). - window.ga = function() { console.log("would send to GA", arguments) }; - window.gtag = function() { console.log("would send to GA4", arguments) }; + +if typeof(ExposedSettings.gaTokenV4) === "undefined" + script(type="text/javascript", nonce=scriptNonce). + window.gtag = function() { console.log("would send to GA4", arguments) }; +if typeof(ExposedSettings.gaToken) === "undefined" + script(type="text/javascript", nonce=scriptNonce). + window.ga = function() { console.log("would send to GA", arguments) };