Add support for Plausible analytics.

This commit is contained in:
Fredrik Jonsson 2021-01-31 10:30:55 +01:00
commit 141f2f7b6d
2 changed files with 6 additions and 0 deletions

View file

@ -184,6 +184,8 @@ params:
mobileMenu: true # Turn on a mobile menu on small screens.
piwikSiteId: # Matamo site id
piwikTrackerUrl: "" # Matamo url, schemaless and no slash on end (example.org/matamo).
plausibleSiteID: "" # Plausible site id/domain.
plausibleTrackerURL: "" # Plausible url, schemaless and no slash on end. Optional, defaults to "plausible.io/…"
poweredby: true # Show powered by hugo in footer
privacyPolicyUrl: "" # If set will add link to cookie consent form.

View file

@ -4,6 +4,10 @@
<script defer src="https://{{ .Site.Params.piwikTrackerUrl }}/matomo.js"></script>
{{ end -}}
{{ if .Site.Params.plausibleSiteID -}}
<script async defer data-domain="{{ .Site.Params.plausibleSiteID }}" src="{{ .Site.Params.plausibleTrackerURL | default "https://plausible.io/js/plausible.js" }}"></script>
{{ end -}}
{{ if .Site.GoogleAnalytics -}}
{{ $script := resources.Get "js/tracking.js" | resources.ExecuteAsTemplate "js/tracking.js" . | minify | fingerprint -}}
<script src="{{ $script.RelPermalink }}"></script>