Move Google Analytics to gtag.js

This commit is contained in:
2020-12-06 14:43:40 +01:00
parent 4c2b22a349
commit 9a946495a1
+14 -1
View File
@@ -66,4 +66,17 @@
type="application/json" title="{{ .Site.Title }}" />
{{ end }}
{{ template "_internal/google_analytics_async.html" . }}
{{ if .Site.GoogleAnalytics }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '{{ .Site.GoogleAnalytics }}');
</script>
{{ end }}