Browsers keep cookies separate for each site. An analytics id stored on example.com cannot be read on example-app.io. So when someone reads your marketing site and then signs up in your app on another domain, a basic setup sees two people: one who left, and a new one who arrived from a referral, your own marketing site. The sign-up, and any revenue, is credited to the wrong place.
When you need it
- A marketing site and an app on different domains (
brand.comandbrandapp.io). - Separate country sites (
example.de,example.fr) under one analytics property. - A shop or booking system you host on its own domain.
You do not need it for subdomains of one domain, such as www.example.com and app.example.com. Those can share cookies; see subdomain tracking.
How it works in general
Because cookies cannot travel, the id travels in the link. When a visitor clicks from domain A to domain B, the script adds a parameter carrying the visitor id to the link. On domain B, the script reads it, stores the same id in its own cookies and carries on.
The weak spot is that anyone could copy such a link and share it, making strangers look like one visitor. Good implementations limit how long the parameter is valid and where it is accepted from.
How Reveata does it
- Add the other root domain under Settings → General → Additional domains. Up to 20 additional domains are allowed per website.
- Use the same snippet on each domain, listing the others in
data-domains:
<script defer data-website-id="ws_your_tracking_id" data-domains="example-app.io" src="https://reveata.com/js/script.js"></script>At the moment of the click, the script adds a short _dt parameter to links to those domains. The other domain accepts it only if the link is less than 2 minutes old, the page was opened from one of its own data-domains (the referrer says so) and the ids are well formed. It then stores the ids and removes _dt from the address bar. A copied or old link simply starts a new visitor (Cross-domain tracking).
Links you open from JavaScript are not clicked, so pass them through reveata.decorate(url) first (JavaScript API).
Limits to know
- Only real link clicks. Redirects from your server, forms posting to the other domain and
window.locationchanges carry no id unless decorated. - The referrer must arrive.
Referrer-Policy: no-referrerorrel="noreferrer"on the link removes it, and the ids are ignored. The browser default works. See Referrer-Policy. - Cookieless mode stores no ids, so there is nothing to pass. Visits only join up when the server's daily id matches.
- Hosted checkouts from Stripe, Polar or Dodo Payments are linked through the checkout itself, not cross-domain tracking (Connect a payment provider).
Testing it
Open the first domain in a private window from a link ending in ?ref=crossdomain-test, click through to the other domain, and check Realtime: you should see one visitor whose pages span both hosts, still credited to crossdomain-test.