03 / 08

Subdomain tracking

Track www, app and every subdomain as one site, or measure each on its own.

Track every subdomain as one site

To roll www, app, blog and the apex into a single project, ship the same tag on each one and set data-site to your apex domain everywhere. The collect endpoint accepts a beacon when its browser origin is the site or any subdomain of it, so every host reports into the one site ID.

<!-- The same tag on www.example.com, app.example.com, blog.example.com … -->
<script defer src="https://analytics.motion.dev/tracker.js" data-site="example.com"></script>

Visitor counts, the previous-page flow and campaign attribution all work across the subdomains as if they were one site. The real host of each view is recorded too, so a cross-subdomain journey stays coherent rather than looking like two separate visits.

Or keep them separate

Want app.example.com and your marketing site measured on their own? Register each host as its own site and set data-site to that exact hostname. Each one then counts independently and draws on the same pooled monthly pageviews.

<!-- app.example.com tracked as its own site -->
<script defer src="https://analytics.motion.dev/tracker.js" data-site="app.example.com"></script>

Leaving data-site off altogether falls back to the page's own hostname, which tracks each subdomain separately by accident. Set it explicitly to get the grouping you intend.