Debian Codegraph @

tpl/tplimpl/embedded/templates/_partials/google_analytics.html

raw
1 {{ if not site.Config.Privacy.GoogleAnalytics.Disable }}
2 {{- with site.Config.Services.GoogleAnalytics.ID }}
3 {{- if strings.HasPrefix (lower .) "ua-" }}
4 {{- warnf "Google Analytics 4 (GA4) replaced Google Universal Analytics (UA) effective 1 July 2023. See https://support.google.com/analytics/answer/11583528. Create a GA4 property and data stream, then replace the Google Analytics ID in your project configuration with the new value." }}
5 {{- else }}
6 <script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
7 <script>
8 var doNotTrack = false;
9 if ({{ site.Config.Privacy.GoogleAnalytics.RespectDoNotTrack }}) {
10 var dnt = (navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack);
11 var doNotTrack = (dnt == "1" || dnt == "yes");
12 }
13 if (!doNotTrack) {
14 window.dataLayer = window.dataLayer || [];
15 function gtag(){dataLayer.push(arguments);}
16 gtag('js', new Date());
17 gtag('config', '{{ . }}');
18 }
19 </script>
20 {{- end }}
21 {{- end }}
22 {{- end -}}