support seline analytics

This commit is contained in:
Weaxs 2024-07-26 10:17:39 +08:00
parent 18ed67b2e6
commit bcc26c11b8
4 changed files with 29 additions and 0 deletions

View file

@ -136,6 +136,10 @@ disableTextInHeader = false
# domain = "llama.yoursite.com"
# dataDomains = "yoursite.com,yoursite2.com"
[selineAnalytics]
# token = "XXXXXX"
# enableTrace = false
[buymeacoffee]
# identifier = ""
# globalWidget = true

View file

@ -135,6 +135,10 @@ smartTOCHideUnfocusedChildren = false
# domain = "llama.yoursite.com"
# dataDomains = "yoursite.com,yoursite2.com"
[selineAnalytics]
# token = "XXXXXX"
# enableTrace = false
[buymeacoffee]
identifier = "nunocoracao"
globalWidget = true

View file

@ -6,4 +6,7 @@
{{ end }}
{{ with site.Params.umamiAnalytics.websiteid }}
{{ partial "analytics/umami.html" }}
{{ end }}
{{ with site.Params.selineAnalytics.token }}
{{ partial "analytics/seline.html" }}
{{ end }}

View file

@ -0,0 +1,18 @@
<script async src="https://cdn.seline.so/seline.js" data-token="{{ site.Params.selineAnalytics.token }}" data-id="seline-script"></script>
{{ if .Site.Params.selineAnalytics.enableTrace | default false }}
<script type="text/javascript">
document.querySelector('script[data-id="seline-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');
seline.track("user:" + type + ':' + title, {
type: type,
title: title,
url: url
});
});
</script>
{{ end }}