Skip to content

Tracker script

The tracker is the script.js you add to your site. This page lists everything you can configure on it.

<script
defer
src="https://hub.madinco.com/script.js"
data-website-id="YOUR_WEBSITE_ID"
></script>
Attribute Required Description
data-website-id Yes The ID of the website this page belongs to.
data-host-url No Send data to a different collector host than the script’s origin.
data-auto-track No Set to false to stop the tracker starting automatically. When disabled, nothing is tracked until you call the tracker’s API yourself.
data-auto-pageview No Set to false to keep the tracker running (click and performance tracking still work) without recording page views automatically.
data-do-not-track No Set to true to respect the browser’s Do Not Track signal.
data-domains No Comma-separated allowlist of hostnames the tracker runs on.
data-tag No Attach a label to every event from this script (e.g. a build or campaign).
data-exclude-search No Set to true to drop the query string from tracked URLs.
data-exclude-hash No Set to true to drop the fragment from tracked URLs.
data-fetch-credentials No The credentials mode used for the collector request (e.g. include). Omitted by default.
data-performance No Set to true to also report Core Web Vitals for each page.
data-before-send No Name of a global function to run before each payload is sent — return a modified payload, or a falsy value to cancel sending.

With data-auto-track and data-auto-pageview both enabled (the default), the tracker follows client-side route changes automatically via the History API — so SPAs and frameworks record page views on navigation without extra work.

To take full control, disable automatic page views and send them yourself:

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

Calling mad.track() with no arguments records a page view for the current URL.

Once the script loads, a global mad object is available. window.umami is also set as an alias, so snippets written for Umami’s tracker work here without changes.

Method Description
mad.track() Record a page view for the current URL.
mad.track(name, props?) Record a custom event. See Custom events.
mad.identify(id, data?) Attach a visitor identifier (and optional traits) to the current and future events in this session.
mad.getSession() Read the tracker’s current session cache and website ID.

If your code runs before the script finishes loading, guard the call:

window.mad?.track('signup');