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 }}
|
2018-08-06 17:11:12 -04:00
|
|
|
<script type="application/javascript">
|
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 -}}
|