Where to put code for Single-Page Application Tracking


Hi everybody,

I have a single-page web application. When clicking on links, some content is exchanged and the URL changes as well.

So I want to follow this description: Single-Page Application Tracking: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

I also saw the Complete Example code. But I do not get it work. Where do I need to add the window.addEventListener code? Within the default tracking code of my site?

Thanks for your help.