hugo-toha/layouts/partials/analytics.html
Pablo Marcos 91b18c0f04
Add analytics template + Add Ko-Fi donation button + Host fonts locally (#530)
* Add Blogtrottr as newsletter provider

* Fixed absLangURL issue with sections in footer

* Fixes LaTeX support

Makes scripts fully local and only loads them if math:true. Adds support for 18462\latex18462 or even $\latex$

* Added 2 New, Privacy-Friendly Analytics Methods

Counter.dev and GoatAnalytics. Google Analytics should keep working the same

* Removed 1 CDN

* Moved params under features

* Added Ko-Fi floating button for support

* Refactor analytics code + Add local fonts

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

Co-authored-by: Pablo Marcos <codebergflamingo@staplehorse.anonaddy.com>
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
2022-03-14 22:01:49 +06:00

46 lines
1.6 KiB
HTML

<!-- Add Analytics if enabled in configuration -->
{{ with site.Params.features.analytics }}
{{ if .enabled }}
<!-- Google Analytics -->
{{ with .google }}
{{ $privacyConfig:= dict (slice "Site" "Config" "Privacy" "GoogleAnalytics") $.Site.Config.Privacy.GoogleAnalytics }}
{{ $analyticsConfig := dict (slice "Site" "GoogleAnalytics") .id }}
{{ template "_internal/google_analytics.html" (merge $privacyConfig $analyticsConfig) }}
{{ end }}
<!-- Counter.dev -->
{{ with .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: "{{ .id }}",
utcoffset: "1",
})
);
}
sessionStorage.setItem("_swa", "1");
</script>
{{ end }}
<!-- GoatCounter -->
{{ with .goatCounter }}
<script
data-goatcounter="https://{{ .code }}.goatcounter.com/count"
async
src="//gc.zgo.at/count.js"
></script>
{{ end }}
{{ end }}
{{ end }}
<!-- Keep backwards compatibility and consistency with HUGO defaults -->
{{ if site.GoogleAnalytics }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}