mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-22 14:35:43 -06:00
support umamiAnalytics
This commit is contained in:
parent
bafc42f587
commit
a0d05ce208
4 changed files with 34 additions and 0 deletions
|
@ -129,6 +129,10 @@ disableTextInHeader = false
|
|||
# site = "ABC12345"
|
||||
# domain = "llama.yoursite.com"
|
||||
|
||||
[umamiAnalytics]
|
||||
# websiteid = "ABC12345"
|
||||
# domain = "llama.yoursite.com"
|
||||
|
||||
[buymeacoffee]
|
||||
# identifier = ""
|
||||
# globalWidget = true
|
||||
|
|
|
@ -128,6 +128,10 @@ smartTOCHideUnfocusedChildren = false
|
|||
# site = "ABC12345"
|
||||
# domain = "llama.yoursite.com"
|
||||
|
||||
[umamiAnalytics]
|
||||
# websiteid = "ABC12345"
|
||||
# domain = "llama.yoursite.com"
|
||||
|
||||
[buymeacoffee]
|
||||
identifier = "nunocoracao"
|
||||
globalWidget = true
|
||||
|
|
|
@ -3,4 +3,7 @@
|
|||
{{ end }}
|
||||
{{ with site.Config.Services.GoogleAnalytics.ID }}
|
||||
{{ partial "analytics/ga.html" }}
|
||||
{{ end }}
|
||||
{{ with site.Params.umamiAnalytics.websiteid }}
|
||||
{{ partial "analytics/umami.html" }}
|
||||
{{ end }}
|
23
layouts/partials/analytics/umami.html
Normal file
23
layouts/partials/analytics/umami.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{{ if isset site.Params.umamiAnalytics "domain" }}
|
||||
<script id="umami-script" async src="https://{{ site.Params.umamiAnalytics.domain }}/script.js" data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
document.querySelector('#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});
|
||||
});
|
||||
</script>
|
||||
{{ else }}
|
||||
<script async src="https://analytics.umami.is/script.js" data-website-id="{{ site.Params.umamiAnalytics.websiteid }}">
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
document.querySelector('#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});
|
||||
});
|
||||
</script>
|
||||
{{ end }}
|
Loading…
Reference in a new issue