re-add matomo

This commit is contained in:
2026-05-25 16:49:05 +02:00
parent bae57fda31
commit 1fd7cffbb6
+38 -1
View File
@@ -5,6 +5,43 @@
</template>
<script setup lang="ts">
import { onMounted } from 'vue'
import AppLayout from './layout/AppLayout.vue'
import { RouterView } from 'vue-router'
import { RouterView, useRouter } from 'vue-router'
const router = useRouter()
onMounted(() => {
const _paq = ((window as any)._paq = (window as any)._paq || [])
_paq.push(['enableLinkTracking'])
const u = '//matomo.vps.teletype.hu/'
_paq.push(['setTrackerUrl', u + 'matomo.php'])
_paq.push(['setSiteId', '1'])
_paq.push(['setCustomUrl', window.location.href])
_paq.push(['setDocumentTitle', document.title])
_paq.push(['trackPageView'])
const d = document
const g = d.createElement('script')
const s = d.getElementsByTagName('script')[0]
g.async = true
g.src = u + 'matomo.js'
s.parentNode!.insertBefore(g, s)
})
router.beforeEach((_to, from) => {
const _paq = (window as any)._paq
if (_paq && from.fullPath) {
_paq.push(['setReferrerUrl', window.location.origin + from.fullPath])
}
})
router.afterEach((to) => {
const _paq = (window as any)._paq
if (!_paq) return
_paq.push(['setCustomUrl', window.location.origin + to.fullPath])
setTimeout(() => {
_paq.push(['setDocumentTitle', document.title])
_paq.push(['trackPageView'])
}, 0)
})
</script>