hugo/tpl/tplimpl/embedded/templates/google_analytics_async.html

30 lines
1 KiB
HTML
Raw Normal View History

{{ warnf "_internal/google_analytics_async.html is no longer supported by Google and will be removed in a future version of Hugo" }}
{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}}
{{- if not $pc.Disable -}}
{{ with .Site.Config.Services.GoogleAnalytics.ID }}
<script>
{{ template "__ga_js_set_doNotTrack" $ }}
if (!doNotTrack) {
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
{{- 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 }}
ga('create', '{{ . }}', 'auto');
{{ end -}}
2018-05-25 10:05:45 -04:00
{{ if $pc.AnonymizeIP }}ga('set', 'anonymizeIp', true);{{ end }}
ga('send', 'pageview');
}
</script>
2018-06-09 17:47:44 -04:00
<script async src='https://www.google-analytics.com/analytics.js'></script>
{{ end }}
2018-06-09 17:47:44 -04:00
{{- end -}}