Skip to content

Matomo not tracking on navigation #448

Open
@Honigbrot

Description

@Honigbrot

📚 What are you trying to do?

I've been trying to setup Matomo tracking but it only tracks the pageview on hard refreshes.

🔍 What have you tried?

So far I've created a client plugin (url omitted).

export default defineNuxtPlugin((nuxtApp) => {
    const router = useRouter()

    const {proxy} = useScriptMatomoAnalytics({
        matomoUrl: 'https://',
        siteId: '1',
        disableCookies: true,
        enableLinkTracking: true,
        trackPageView: false
    })

    if (process.client) {
        router.afterEach((to) => {
            setTimeout(() => {
                proxy._paq.push(['setDocumentTitle', document.title])
                proxy._paq.push(['setCustomUrl', window.location.pathname + window.location.search])
                proxy._paq.push(['trackPageView'])
            }, 100)
        })
    }
})

I've also tried a nuxt finish hook and a watcher without success.

ℹ️ Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions