Guides
Cross-domain tracking: keep one visitor across sites
Published November 12, 2026 · 8 min read
Your website is on yourcompany.com, the shop lives on shop.yourcompany.com and bookings run on another domain from your provider. To your analytics, someone who reads an article, moves to the shop and buys can look like two or three different people, and the visit that brought the sale gets lost along the way.
Cross-domain tracking makes that path count as one visitor. This guide explains when you need it, how it works while respecting consent and how to check it is set up correctly.
Key takeaways
- Each domain keeps its own cookies, so a visitor who changes domain shows up as new unless you do something.
- In Flowgration, even a subdomain counts as another domain: the tracker's cookies are not shared between subdomains.
- Cross-domain tracking passes the visitor ID in the link, and only after they accept analytics.
- It must be switched on for every site on the path; without that setting, an ID in the URL is ignored.
- Test it by hand before you trust the reports.
What is cross-domain tracking?
It keeps the same visitor ID when someone moves from one domain to another domain you also measure. Because cookies belong to a specific domain, the destination site can't read the cookie of the source site. The usual fix is to add the ID to the link at the moment of the click, so the destination can adopt it.
When do you need it?
| Situation | Do you need it? |
|---|---|
| One website on one domain | No |
| Website on www and shop on a subdomain | Yes, if you measure both with the same tracker |
| Website on one domain, bookings or checkout on another domain you own | Yes |
| Several unrelated brand websites | Usually not |
| A third-party payment gateway | You can't measure inside it; measure the return page |
What matters is the business question: do you want to know which campaign or page on your website led to a sale that closed on another domain? If so, you need to join both sides.
Why does a subdomain count as another domain?
Some analytics tools write their cookie for the whole parent domain. Flowgration's tracker writes it only for the exact host where it loads, which is stricter and easier to explain in your cookie policy. The consequence is that www.yourcompany.com and shop.yourcompany.com don't share a visitor unless you switch on cross-domain tracking.
How does it work without bypassing consent?
There are four steps:
- The visitor accepts analytics on the source site.
- On click, when they follow a link to one of the configured domains, the tracker adds the
_fgvparameter with their ID. - On the destination, if the tracker there has the same setting and the visitor has consented there too, it adopts that ID and starts a new session.
- The parameter is removed from the address bar with
history.replaceState, so it isn't copied if the person shares the link.
Without consent nothing is added to the link. And if the destination site doesn't have the setting, a _fgv in the URL is ignored: a link shared on social media won't merge two different people.
Remember that consent is asked on each domain. If your cookie tool doesn't share the decision across domains, the visitor will see the banner on both, and nothing is joined unless they accept on the destination.
How do you set it up, step by step?
- List every domain on the path, subdomains included: www, shop, bookings, app.
- Register each domain on the analytics site. Putting them all on the same site is simplest; they can also be separate sites in the same organisation.
- Add the attribute to the tracker tag on every site:
<script async src="https://app.flowgration.com/t/fg.js"
data-site="fgs_your_key"
data-cross-domain="shop.yourcompany.com,bookings.yourcompany.com"></script>
- JavaScript redirects. If a button sends people to the other domain with code rather than a link, decorate the URL before redirecting:
flowgration('crossDomainUrl', 'https://shop.yourcompany.com/cart', function (url) {
window.location.href = url;
});
- Forms that post with JavaScript, or sign-ups in another app: read the ID with
flowgration('visitorId', fn)and send it asfg_vidin the request body.
Testing checklist
Run this test in a private window before you call the setup done:
- Reject cookies on the source site, click through to the destination and check the link carries no
_fgv. - Accept cookies, click again and check the link does carry
_fgv. - On the destination, accept cookies and check
_fgvdisappears from the address bar. - Open the browser's developer tools and compare the
_fgvcookie on both domains: it should hold the same value. - Also test a middle click (open in a new tab).
- If you use code redirects, test that specific button.
- Copy a destination URL with a made-up
_fgvand open it in another browser without the setting: it shouldn't join anyone.
Keep in mind that data is processed every five minutes, so a visit can take 5 to 10 minutes to appear in the reports.
Common mistakes
- Adding the attribute only on the source site. The destination ignores the ID if it doesn't have the setting.
- Forgetting to register the destination domain. The server drops events from domains that aren't on the list.
- Moving the visitor with code without decorating the URL. The link carries no ID and the visitor looks new.
- Expecting to see inside an external payment gateway. It isn't your domain; measure the confirmation page.
Frequently asked questions
Is it legal to pass the ID in the URL?
It is only added after the visitor accepts analytics, and it is removed from the address bar on arrival. Even so, mention it in your cookie policy and check with your adviser. You are the data controller.
Does it work in cookieless mode?
No. Cookieless mode has no visitor ID, so there is nothing to pass between domains. Each domain counts its pages separately.
Do I need one site per domain?
No. You can register several domains on the same site, which is simplest, or use separate sites in the same organisation.
Can two people get merged if someone shares a link?
It shouldn't happen. The parameter is removed on arrival, and a destination without the setting ignores it.
How Flowgration does it
Cross-domain tracking in Flowgration's web analytics is opt-in and is switched on with the data-cross-domain attribute on every site on the path. With consent, clicks on links to those domains carry _fgv; flowgration('crossDomainUrl', url, fn) covers code redirects. The destination adopts the ID only if it has the attribute and the visitor has accepted there, starts a new session and cleans the URL.
The server only accepts events from domains registered on the site or on another site in your organisation. If an identified visitor browses several domains, their whole path appears on the contact record.
Limits: it doesn't work in cookieless mode, it can't measure inside third-party gateways and consent is asked on each domain. To see why your numbers may not match other tools, read why GA4 and CRM numbers differ.
Build your WooCommerce CRM in 60 seconds
Flowgration turns your store's orders into a living CRM and runs email, SMS and WhatsApp on autopilot. Free up to 500 contacts.
Start free