hugo-toha/layouts/partials/analytics.html
2022-02-17 16:41:43 +01:00

33 lines
1.5 KiB
HTML

<!-- Add Analytics if enabled in configuration -->
{{ if eq site.Params.Features.analytics.enable true }}
<!-- Google Analytics -->
{{ if site.Params.Features.analytics.Google }}
<!-- Google Analytics v3 ID -->
{{ if hasPrefix site.Params.Features.analytics.Google "UA-"}}
{{ template "_internal/google_analytics_async.html" . }}
<!-- Google Analytics v4 ID -->
{{ else }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ end }}
<!-- Counter.dev -->
{{ if site.Params.Features.analytics.CounterDev }}
<script>if(!sessionStorage.getItem("_swa")&&document.referrer.indexOf(location.protocol+"//"+location.host)!== 0){fetch("https://counter.dev/track?"+new URLSearchParams({referrer:document.referrer,screen:screen.width+"x"+screen.height,user:"{{ site.Params.Features.analytics.CounterDev }}",utcoffset:"1"}))};sessionStorage.setItem("_swa","1");</script>
{{ end }}
<!-- Counter.dev -->
{{ if site.Params.Features.analytics.GoatCounter }}
<script data-goatcounter="https://{{ site.Params.Features.analytics.GoatCounter }}.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
{{ end }}
<!-- Keep backwards compatibility and consistency with HUGO defaults -->
{{ else if site.GoogleAnalytics }}
{{ if hasPrefix site.GoogleAnalytics "UA-"}}
{{ template "_internal/google_analytics_async.html" . }}
{{ else }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ end }}