Abstract network of connected nodes representing visitors moving between domains

Cross-Domain Tracking: How to Follow Visitors Across Multiple Sites

Plenty of businesses run on more than one domain. Your marketing site lives on example.com, your app on app.example.io, and your checkout on a payment provider's domain. A visitor moves through all three in a single journey — but to standard analytics, that one person looks like three separate visitors. Cross-domain tracking fixes this by keeping one real visit as one session, even as the domain changes.

Why Sessions Break Between Domains

Analytics identifies a returning visitor using an identifier — typically a value stored in a first-party cookie or in localStorage. By design, that storage is scoped to a single domain. A cookie set on example.com is completely invisible to app.example.io. When the visitor crosses from one domain to the other, the second site can't read the first site's identifier, so it generates a brand-new one and starts a fresh session.

The result is double-counting and broken journeys. A single person who reads your homepage, clicks through to your app, and signs up appears as: one visitor on the marketing site who "bounced," plus a separate, brand-new "direct" visitor on the app. The referral chain that connects them is lost, and your referral traffic data gets messy.

How Cross-Domain Tracking Works

Since the destination domain can't read the source domain's stored ID, the trick is to carry the ID across in the link itself. When a visitor clicks a link from example.com to app.example.io, the tracker appends the visitor's ID to the destination URL as a query parameter. The destination site reads that parameter on arrival and adopts the same ID instead of minting a new one.

The link decoration pattern

// On the source domain: add the visitor ID to outgoing links const LINKED = ['app.example.io', 'checkout.example.com']; document.addEventListener('click', e => { const a = e.target.closest('a'); if (a && LINKED.includes(a.host)) a.href += (a.search ? '&' : '?') + '_sx=' + visitorId; }); // On the destination domain: read the ID on arrival const incoming = new URLSearchParams(location.search).get('_sx'); if (incoming) adoptVisitorId(incoming);

The two sites must share the same analytics property and agree on the parameter name, so the handoff is recognized rather than treated as just another UTM tag. Done correctly, the visitor keeps one ID for the entire journey and the session stays intact.

Subdomains are easier. If all your properties are subdomains of one root (www.example.com, app.example.com), you can set the cookie at the root-domain level (.example.com) and skip link decoration entirely. True cross-domain tracking is only needed when the registered domains differ.

What Cross-Domain Tracking Reveals

Once sessions are stitched together, you can see journeys that were previously invisible:

Without stitchingWith cross-domain tracking
2 visitors, both "bounced"1 visitor, 6-page journey
App signups look "direct"Signups credited to the blog post that started them
Two short sessionsOne accurate session duration

This matters most for attribution. Without it, the marketing content that actually drives signups gets no credit, because the conversion happens on a different domain that records the visit as "direct." With it, you can finally trace a paid signup back to the specific article or ad that started the journey — the foundation of any honest funnel analysis.

Things to Watch Out For

Track every domain you own from one statpx account

Add multiple sites under one login, organize them with tags, and see each property's traffic side by side. Start free and connect your whole web presence in minutes.

Start tracking free →

The Bottom Line

If your customer journey spans more than one domain, default analytics is quietly miscounting your visitors and misattributing your conversions. Cross-domain tracking carries a single anonymous identifier across the handoff so one real person stays one session from first click to final conversion. Set it up once, verify it by walking the journey yourself, and your attribution and session numbers will finally reflect reality. For the basics of getting tracking onto each site first, see our guide to installing the tracking snippet.

Continue reading

Technical
How to Identify and Block Referrer Spam in Website Analytics
Technical
How to Filter Your Own Visits Out of Website Analytics
Technical
Custom Dimensions in Analytics: Track Extra Context Beyond Pageviews
Analytics by statpx