SPA support

This commit is contained in:
John Barker 2025-07-18 22:51:45 +01:00
parent 1446d5d2cf
commit 7fd5e7ce59

View File

@ -209,6 +209,14 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
matomoScript.innerHTML = \`
var _paq = window._paq = window._paq || [];
var currentUrl = location.href;
// https://developer.matomo.org/guides/spa-tracking
// Track SPA navigation
document.addEventListener("nav", () => {
_paq.push(['setCustomUrl', location.pathname]);
_paq.push(['setDocumentTitle', document.title]);
_paq.push(['trackPageView']);
});
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);