Matomo Analytics with Page Transitions (Barba.js)

47 views Asked by At

I'm wondering what the best approach is to implement Matomo Analytics in a website that dosen't reload on navigation but only injects new content in the body of the html.

My site is using Barba.js to transition pages. The Matomo script is located in the head (which dosen't change). So only the first page load is tracked. Is there a possibility to load the script in the body every navigation?

Matomo also has "Events", I guess I could use them to track how the user navigates. But then I will have a set of data tracking the initially loaded pages and a separate sheet of data with the tracked events. This would be very inconsistent tracking data and hard to conclude insights from.

I would love some advice on this topic. Cheers!

1

There are 1 answers

0
danielpradilla On

You can trigger a trackPageview event manually, that will count as a pageview:

https://developer.matomo.org/guides/spa-tracking

Or, if you site changes its URL on every content change, then you can use the History Change event in the Tag Manager. Works out of the box with no extra config or coding:

https://matomo.org/faq/how-to/faq_23636/