Quick answer: Cross-domain tracking tells Google Analytics that a visit to your main site and a visit to a second domain (a shop, booking engine or payment page) belong to the same session. Without it, the second domain records a new user and your own site shows up as the referral source. You fix it by configuring the linker in analytics.js, gtag.js or Google Tag Manager on every domain, adding the domains to the referral exclusion list, and testing that the client ID carries across.
Many businesses run more than one domain without thinking of it as a tracking problem. A marketing site on one domain, an ecommerce store on another, a hosted booking tool on a third. Each handoff can break attribution, so a sale that started with an AdWords click or an organic search ends up credited to “referral from yourdomain.com”.
This guide explains how the problem happens and how to set up cross-domain tracking in Universal Analytics properly.
Why sessions split between domains
Universal Analytics identifies a browser with a client ID stored in a first-party cookie (_ga). Cookies belong to a domain. When a visitor clicks from example.com to example-shop.com, the second domain cannot read the first domain’s cookie, so Analytics creates a new client ID.
The results:
- One visitor counted as two users
- A new session starting on the second domain
- The original traffic source replaced by a self-referral
- Goal and ecommerce conversions credited to the wrong channel
Subdomains are a different case. www.example.com and shop.example.com can share the cookie when it is set on example.com (the default cookieDomain: 'auto' handles this). You still need consistent tracking code, but not the full cross-domain linker.
When you need cross-domain tracking
- Main site and store on separate domains
- A third-party booking or ticketing system on its own domain that lets you add your tracking code
- Regional sites on different country domains that share one property
- Separate landing page domains that send people to the main site to convert
If the third-party system does not let you add your Analytics code, cross-domain tracking cannot work there. In that case, track the handoff click as an event and use the vendor’s own reporting or a confirmation-page integration.
Before you start
- Use one Universal Analytics property (one UA-XXXXX-Y ID) on all domains involved
- Confirm the same tracking method is used everywhere (analytics.js, gtag.js, or GTM)
- Make a list of every domain and subdomain in the visitor’s path
- Work on a test view or keep an unfiltered view so you can compare before and after
If your basic install is shaky, sort it out first with our Google Analytics setup guide.
Setup with analytics.js
On every domain, load the linker plugin and tell it which domains to decorate:
ga('create', 'UA-XXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['example.com', 'example-shop.com']);
ga('send', 'pageview');
autoLink adds a _ga parameter to links and form submissions that point at the listed domains. The receiving domain, with allowLinker set to true, reads that parameter and reuses the client ID.
Setup with gtag.js
The global site tag, released in late 2017, configures linking in the config call:
gtag('config', 'UA-XXXXX-Y', {
'linker': {
'domains': ['example.com', 'example-shop.com']
}
});
Place the same configuration on both domains. If you also use gtag.js for AdWords, keep one gtag.js library load and add each product’s config line.
Setup with Google Tag Manager
In the Universal Analytics tag (or the Google Analytics Settings variable):
- Under Fields to Set, add
allowLinkerwith the valuetrue - Under Cross Domain Tracking, enter the domains in Auto Link Domains, comma separated
- Enable Decorate Forms if visitors submit forms that post to the other domain
- Publish the same setup in the container used on every domain (or in each domain’s container if they differ)
Preview mode lets you click across domains and confirm the _ga parameter appears on the destination URL.
Add referral exclusions
In Analytics, go to Admin, Property, Tracking Info, Referral Exclusion List, and add each of your own domains. This stops a returning visitor’s session from restarting with your own site as the source.
Also add payment gateways that bounce visitors back to your site after checkout (PayPal is the common example). Otherwise many sales will be credited to “paypal.com / referral”.
Show the hostname in reports
By default, the All Pages report shows only the path. /checkout/ on two domains looks the same. Add a view filter (Custom, Advanced) that prepends the hostname to the Request URI, or add Hostname as a secondary dimension when you analyse pages. Do this in a separate view first so you do not damage historical reporting.
Test it properly
- Open the first domain in a private window with Tag Assistant or the GA debugger running
- Note the client ID (in the
_gacookie) - Click through to the second domain and check the URL carries
_ga=... - Confirm the
_gacookie on the second domain shows the same client ID - Check the Real-Time report: the session should continue, with no new referral from your own domain
Repeat with forms, buttons generated by JavaScript, and links inside iframes. Iframes and JavaScript redirects are the usual weak points and may need manual decoration with the linker’s decorate method.
Common problems
Links built by JavaScript. autoLink listens for clicks on anchor elements. Custom handlers that set window.location need manual decoration.
Redirects that drop the parameter. If the destination redirects to another URL and strips query strings, the _ga value is lost. Fix the redirect to keep parameters.
Iframes. An embedded booking widget from another domain needs the linker applied to the iframe source, plus tracking inside the iframe.
Mismatched property IDs. Linking only works within one property.
Self-referrals still showing. Check the referral exclusion list and that every page on every domain has the code. A single page without tracking breaks the chain.
A note on privacy
The linker adds an identifier to URLs, which can end up in server logs and in third-party referrers. Keep it limited to your own domains. With GDPR coming into force in May 2018, review how your privacy notice describes Analytics across domains, especially if one domain belongs to a partner.
FAQ
Do I need cross-domain tracking for subdomains?
Usually not. Use cookieDomain: 'auto' and the same property ID, and add the root domain to the referral exclusion list if needed.
Will it fix past data?
No. It applies from the moment you deploy. Annotate the change date in Analytics.
Can I track a third-party checkout I cannot edit?
Only partially. Track the outbound click as an event, then look for a vendor integration or a post-purchase callback to your own site.
Does the linker hurt SEO?
The parameter appears on clicks between your domains, not in the links search engines crawl on your pages. Keep canonical tags in place on the destination pages to be safe.
Keep each visitor in one story
Cross-domain tracking is a small configuration change that fixes inflated user counts, self-referrals and broken attribution. Set up the linker on every domain, exclude your own domains as referrers, show hostnames in reports and test the full path. If you want help making sure your reports reflect the real customer path so you know what’s working, we can audit and fix your setup.