2023-09-18 15:53:53 -04:00
|
|
|
{{ warnf "_internal/google_analytics_async.html is no longer supported by Google and will be removed in a future version of Hugo" }}
|
2018-05-23 04:03:11 -04:00
|
|
|
{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}}
|
2018-05-20 14:00:29 -04:00
|
|
|
{{- if not $pc.Disable -}}
|
2023-10-16 14:31:09 -04:00
|
|
|
{{ with .Site.Config.Services.GoogleAnalytics.ID }}
|
2023-11-25 15:43:52 -05:00
|
|
|
<script>
|
2018-05-21 04:18:36 -04:00
|
|
|
{{ template "__ga_js_set_doNotTrack" $ }}
|
|
|
|
if (!doNotTrack) {
|
|
|
|
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
2018-05-25 08:52:06 -04:00
|
|
|
{{- if $pc.UseSessionStorage }}
|
|
|
|
if (window.sessionStorage) {
|
|
|
|
var GA_SESSION_STORAGE_KEY = 'ga:clientId';
|
|
|
|
ga('create', '{{ . }}', {
|
|
|
|
'storage': 'none',
|
|
|
|
'clientId': sessionStorage.getItem(GA_SESSION_STORAGE_KEY)
|
|
|
|
});
|
|
|
|
ga(function(tracker) {
|
|
|
|
sessionStorage.setItem(GA_SESSION_STORAGE_KEY, tracker.get('clientId'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
{{ else }}
|
2018-05-21 04:18:36 -04:00
|
|
|
ga('create', '{{ . }}', 'auto');
|
2018-05-25 08:52:06 -04:00
|
|
|
{{ end -}}
|
2018-05-25 10:05:45 -04:00
|
|
|
{{ if $pc.AnonymizeIP }}ga('set', 'anonymizeIp', true);{{ end }}
|
2018-05-21 04:18:36 -04:00
|
|
|
ga('send', 'pageview');
|
|
|
|
}
|
2018-05-04 11:53:56 -04:00
|
|
|
</script>
|
2018-06-09 17:47:44 -04:00
|
|
|
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
2018-05-20 14:00:29 -04:00
|
|
|
{{ end }}
|
2018-06-09 17:47:44 -04:00
|
|
|
{{- end -}}
|