mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2024-12-25 00:04:52 +00:00
fix: fix duplicate link click tracking
This commit is contained in:
parent
11959de11c
commit
7df2bb6f5e
@ -160,6 +160,29 @@
|
||||
)
|
||||
}
|
||||
{{end}}
|
||||
|
||||
// analytics
|
||||
function clickHandler(evt) {
|
||||
const target = evt.target
|
||||
const classNames = target.className.split(" ")
|
||||
const broken = classNames.includes("broken")
|
||||
const internal = classNames.includes("internal-link")
|
||||
plausible("Link Click", {
|
||||
props: {
|
||||
href: target.href,
|
||||
broken,
|
||||
internal,
|
||||
graph: false,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const links = document.querySelectorAll("a")
|
||||
for (link of links) {
|
||||
if (link.className.includes("root-title")) {
|
||||
link.addEventListener('click', clickHandler, {once: true})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const init = (doc = document) => {
|
||||
@ -183,28 +206,6 @@
|
||||
throwOnError : false
|
||||
});
|
||||
{{end}}
|
||||
|
||||
// analytics
|
||||
function clickHandler(evt) {
|
||||
const target = evt.target
|
||||
const classNames = target.className.split(" ")
|
||||
const broken = classNames.includes("broken")
|
||||
const internal = classNames.includes("internal-link")
|
||||
plausible("Link Click", {
|
||||
props: {
|
||||
href: target.href,
|
||||
broken,
|
||||
internal,
|
||||
graph: false,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const links = document.querySelectorAll("a")
|
||||
for (link of links) {
|
||||
link.addEventListener('click', clickHandler)
|
||||
link.addEventListener('auxclick', clickHandler)
|
||||
}
|
||||
};
|
||||
</script>
|
||||
{{if $data.enableSPA | default $.Site.Data.config.enableSPA}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<header>
|
||||
{{ $config := cond (eq $.Site.Language.Lang "en") "config" (printf "config.%s" $.Site.Language.Lang) }}
|
||||
<h1 id="page-title"><a href="{{ "" | absLangURL }}">{{ ( index $.Site.Data $config ).page_title | default $.Site.Data.config.page_title }}</a></h1>
|
||||
<h1 id="page-title"><a class="root-title" href="{{ "" | absLangURL }}">{{ ( index $.Site.Data $config ).page_title | default $.Site.Data.config.page_title }}</a></h1>
|
||||
<div class="spacer"></div>
|
||||
<div id="search-icon">
|
||||
<p>{{ i18n "search" }}</p>
|
||||
|
Loading…
Reference in New Issue
Block a user