Added 2 New, Privacy-Friendly Analytics Methods
Counter.dev and GoatAnalytics. Google Analytics should keep working the same
This commit is contained in:
parent
52cc4461e8
commit
a8a9305a33
3 changed files with 37 additions and 21 deletions
|
@ -9,17 +9,8 @@
|
|||
<!------ ADD PAGE SPECIFIC HEADERS ------->
|
||||
{{ block "header" . }} {{ end }}
|
||||
|
||||
<!-- ADD GOOGLE ANALYTICS IF ENABLED -->
|
||||
{{ if site.GoogleAnalytics }}
|
||||
<!-- Google Analytics v3 ID -->
|
||||
{{ if hasPrefix site.GoogleAnalytics "UA-"}}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
{{ else }}
|
||||
<!-- Google Analytics v4 ID -->
|
||||
{{ template "_internal/google_analytics.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</head>
|
||||
<!--================= add analytics if enabled =========================-->
|
||||
{{- partial "analytics.html" . -}}
|
||||
|
||||
<body data-spy="scroll" data-target="#TableOfContents" data-offset="80">
|
||||
<div class="container-fluid bg-dimmed wrapper">
|
||||
|
|
|
@ -29,16 +29,8 @@
|
|||
<!--================= custom style overrides =========================-->
|
||||
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
|
||||
|
||||
<!-- Add Google Analytics if enabled in configuration -->
|
||||
{{ if site.GoogleAnalytics }}
|
||||
<!-- Google Analytics v3 ID -->
|
||||
{{ if hasPrefix site.GoogleAnalytics "UA-"}}
|
||||
{{ template "_internal/google_analytics_async.html" . }}
|
||||
{{ else }}
|
||||
<!-- Google Analytics v4 ID -->
|
||||
{{ template "_internal/google_analytics.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<!--================= add analytics if enabled =========================-->
|
||||
{{- partial "analytics.html" . -}}
|
||||
</head>
|
||||
<body data-spy="scroll" data-target="#top-navbar" data-offset="100">
|
||||
|
||||
|
|
33
layouts/partials/analytics.html
Normal file
33
layouts/partials/analytics.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!-- Add Analytics if enabled in configuration -->
|
||||
{{ if site.Params.Analytics }}
|
||||
|
||||
<!-- Google Analytics -->
|
||||
{{ if site.Params.Analytics.Google }}
|
||||
<!-- Google Analytics v3 ID -->
|
||||
{{ if hasPrefix site.Params.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.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.Analytics.CounterDev }}",utcoffset:"1"}))};sessionStorage.setItem("_swa","1");</script>
|
||||
{{ end }}
|
||||
|
||||
<!-- Counter.dev -->
|
||||
{{ if site.Params.Analytics.GoatCounter }}
|
||||
<script data-goatcounter="https://{{ site.Params.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 }}
|
Loading…
Add table
Add a link
Reference in a new issue