diff options
author | Geri Ochoa <gerino@protonmail.com> | 2022-08-31 19:24:56 +0300 |
---|---|---|
committer | Geri Ochoa <gerino@protonmail.com> | 2022-08-31 19:35:50 +0300 |
commit | 4a41d9b2de37caecb9532df89c4f867feb0432b3 (patch) | |
tree | 8d729f130cdceb8be2ad0e9b9992a4a610d9b54d /layouts | |
parent | 78a9796fe8dfc72163c3a09448fcfa073050543d (diff) |
Revert "Use gtag.js analytics library for all site tags"
This reverts commit c7c3fa7f4dc2ac318c59a68187b7647aac61e84d.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_internal/google_analytics_gtag.html | 42 | ||||
-rw-r--r-- | layouts/partials/head.html | 5 |
2 files changed, 2 insertions, 45 deletions
diff --git a/layouts/_internal/google_analytics_gtag.html b/layouts/_internal/google_analytics_gtag.html deleted file mode 100644 index 32b6a33..0000000 --- a/layouts/_internal/google_analytics_gtag.html +++ /dev/null @@ -1,42 +0,0 @@ -{{/* - - This is a modified copy of - - https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/google_analytics.html, - - specifically this version: - - https://github.com/gohugoio/hugo/blob/f7e00c039ff3cea5f991b05c1e325666004cf129/tpl/tplimpl/embedded/templates/google_analytics.html - - The only differences between this copy and the original are that we've dropped: - - - The `{{ if hasPrefix . "G-"}}` condition - - The `{{ else }}` block - - The `anonymize_ip` argument to the `gtag()` call, since it is superfluous. - For details, see https://github.com/gohugoio/hugo/issues/10093. - -*/}} - -{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}} -{{- if not $pc.Disable }}{{ with .Site.GoogleAnalytics -}} -<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> -<script> -{{ template "__ga_js_set_doNotTrack" $ }} -if (!doNotTrack) { - window.dataLayer = window.dataLayer || []; - function gtag(){dataLayer.push(arguments);} - gtag('js', new Date()); - gtag('config', '{{ . }}'); -} -</script> -{{- end }}{{ end -}} - -{{- define "__ga_js_set_doNotTrack" -}}{{/* This is also used in the async version. */}} -{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}} -{{- if not $pc.RespectDoNotTrack -}} -var doNotTrack = false; -{{- else -}} -var dnt = (navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack); -var doNotTrack = (dnt == "1" || dnt == "yes"); -{{- end -}} -{{- end -}}
\ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e6ae692..fec2745 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -45,9 +45,8 @@ {{/* To comply with GDPR, cookie consent scripts places in head-end must execute before Google Analytics is enabled */ -}} {{ if hugo.IsProduction -}} - {{ $enableGtagForUniversalAnalytics := not .Site.Params.disableGtagForUniversalAnalytics -}} - {{ if (or $enableGtagForUniversalAnalytics (hasPrefix .Site.GoogleAnalytics "G-")) -}} - {{ template "_internal/google_analytics_gtag.html" . -}} + {{ if hasPrefix .Site.GoogleAnalytics "G-" -}} + {{ template "_internal/google_analytics.html" . -}} {{ else -}} {{ template "_internal/google_analytics_async.html" . -}} {{ end -}} |