felix-berlin / astro-matomo

Matomo integration for Astro
GNU General Public License v3.0
11 stars 2 forks source link

Support Astro `<ViewTransitions />` #42

Open tordans opened 1 week ago

tordans commented 1 week ago

With Astro <ViewTransitions /> enabled https://docs.astro.build/en/guides/view-transitions/, only the first page load (and event tracking) is tracked but no following page navigations.

Following the docs…

…I added this to my layout to get the page tracking working again

    <script>
        document.addEventListener('astro:page-load', () => {
          window._paq = window._paq || []
          window._paq.push(['setDocumentTitle', document.title])
          window._paq.push(['trackPageView'])
        })
    </script>

It would be nice, if the plugin detected that this is needed and added the code itself. Or if there where a config to add them as part of the plugin.

At the very least a hint in the docs would be great to speed up the debugging for the next person :-).

felix-berlin commented 6 days ago

Hey @tordans thx for creating the detailed issue!

I plan to fix this within the next release.