Skip to content

Track a single-page application

With the default settings, the tracker already follows client-side route changes through the History API — pushState and replaceState — so most SPA frameworks work with no extra code once the script tag is on the page.

If your router doesn’t use the History API, or you want to record a view at a specific moment instead, disable automatic page views and call the tracker yourself:

<script
defer
src="https://hub.madinco.com/script.js"
data-website-id="YOUR_WEBSITE_ID"
data-auto-pageview="false"
></script>
mad.track();

See Tracker script for every attribute.