cullmann.io/themes/blowfish/layouts/partials/analytics/umami.html

23 lines
1.1 KiB
HTML
Raw Permalink Normal View History

{{ if isset site.Params.umamiAnalytics "domain" }}
2024-07-15 22:27:55 +02:00
<script data-id="umami-script" async
src="https://{{ site.Params.umamiAnalytics.domain }}/script.js"
data-website-id="{{ site.Params.umamiAnalytics.websiteid }}"
{{ with site.Params.umamiAnalytics.dataDomains }}data-domains="{{ . }}"{{ end }}>
</script>
{{ else }}
2024-07-15 22:27:55 +02:00
<script data-id="umami-script" async src="https://analytics.umami.is/script.js"
data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
</script>
{{ end }}
2024-08-28 22:54:34 +02:00
{{ if .Site.Params.umamiAnalytics.enableTrackEvent | default true }}
<script type="text/javascript">
2024-07-15 22:27:55 +02:00
document.querySelector('script[data-id="umami-script"]')
.addEventListener('load', function () {
const type = document.head.querySelector('meta[property = "og:type"]').getAttribute('content');
let title = document.head.querySelector('meta[property = "og:title"]').getAttribute('content');
let url = document.head.querySelector('meta[property = "og:url"]').getAttribute('content');
umami.track(type + ':' + title, {'url': url});
});
2024-08-28 22:54:34 +02:00
</script>
{{ end }}