Fail to implement matomo in my website

Hi,

I’m currently trying to integrate matomo to a website built on the Single page application mode.
However, matomo doesn’t work on page change, but only when the user connects directly.

The page change is done via complete URLs and not only with url#.
This means that the documentation Single-Page Application Tracking: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3 is not applicable to me.
Do you have an idea of an implementation I could use in this case ?

The beta website is altideal.netlib.re and matomo is on altidealnetlibre.matomo.cloud

Thanks

Hi,

For the idea of the guide to work, you don’t need URLs based on Hashes.
If you use a SPA with some kind of internal routing, Matomo can’t know when a page view is happening.
So whenever a route change is happening, you can have to call the following code with the correct data. The trackPageView will then send this data to Matomo.

_paq.push(['setCustomUrl', '/the_url']);
_paq.push(['setDocumentTitle', 'My New Title']);
_paq.push(['trackPageView']);

So assuming you are using Vue, it might look something like this (ignore the fact that this is a bit needlessly overcomplicated).

And of course you don’t need to do this from scratch: If you are using a popular SPA framework like react, angular or vue, then someone else has already written the code for it: