developer-documentation
developer-documentation copied to clipboard
Update the single-page-tracking tutorial
This page is talking about how to use Matomo in SPAs, but it's referring only to hashchange style navigation.
These days, SPAs are almost exclusively using pushState navigation, so it would make sense to update the documentation. The main points are:
- Whenever your app is calling
pushStateorreplaceState, you might want to call thetrackPageViewmethod - Then you probably want to listen to
window.popstateevents and send atrackPageViewmessage as well
Most of the page can stay as it is, I would just replace the bits about hashchange with pushState.
Thank you for the suggestion @gka
Maybe it even makes sense for the page to explain both methods (not sure?)
I guess it's ok to keep an hashchange example as reference for older apps.