Skip to content

Commit 9665c77

Browse files
authored
Installs GTM instead of just GA4 (#2801)
Signed-off-by: Chris Abraham <[email protected]>
1 parent b0fbd3b commit 9665c77

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

layouts/_default/baseof.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
{{ partial "head.html" . }}
55
</head>
66
<body class="td-{{ .Kind }}">
7+
{{ if hugo.IsProduction }}
8+
<!-- Google Tag Manager (noscript) -->
9+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WJJ7VKZ"
10+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
11+
<!-- End Google Tag Manager (noscript) -->
12+
{{ end }}
713
<header>
814
{{ partial "navbar.html" . }}
915
</header>

layouts/partials/head.html

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,18 @@
4949
{{ partial "hooks/head-end.html" . }}
5050
<!--To comply with GDPR, cookie consent scripts places in head-end must execute before Google Analytics is enabled -->
5151
{{ if hugo.IsProduction }}
52-
{{ if hasPrefix .Site.GoogleAnalytics "G-"}}
53-
{{ template "_internal/google_analytics.html" . }}
54-
{{ else }}
55-
{{ template "_internal/google_analytics_async.html" . }}
56-
{{ end }}
57-
58-
<!-- also include GA4 property -->
59-
<!-- Google tag (gtag.js) -->
60-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T6VMPWFRDW"></script>
61-
<script>
62-
window.dataLayer = window.dataLayer || [];
63-
function gtag(){dataLayer.push(arguments);}
64-
gtag('js', new Date());
52+
{{ if hasPrefix .Site.GoogleAnalytics "G-"}}
53+
{{ template "_internal/google_analytics.html" . }}
54+
{{ else }}
55+
{{ template "_internal/google_analytics_async.html" . }}
56+
{{ end }}
6557

66-
gtag('config', 'G-T6VMPWFRDW');
67-
</script>
58+
<!-- Google Tag Manager -->
59+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
60+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
61+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
62+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
63+
})(window,document,'script','dataLayer','GTM-WJJ7VKZ');</script>
64+
<!-- End Google Tag Manager -->
6865

6966
{{ end }}

0 commit comments

Comments
 (0)