Web and product analytics
How to set up cross-domain tracking in GA4
The short answer
Use the same GA4 measurement ID on every domain, then go to Admin, Data streams, your web stream, Configure tag settings, Configure your domains, and list each domain. GA4 then adds a _gl parameter to links and forms between them so the visitor keeps one user and session. Test by clicking across and checking _gl appears in the destination URL.
On this page 6 sections
When you need it
Cross-domain measurement is for one journey spread over separate registrable domains: a marketing site on example.com with booking on examplebookings.com, or a shop that hands checkout to a different domain. Without it, the second domain sees a new visitor arriving as a referral from the first, and every booking is credited to your own website rather than to the ad that started it. Subdomains of one domain (www.example.com and shop.example.com) share cookies by default and usually need no cross-domain set-up.
Step by step
- Make sure every domain's pages carry the same Google tag with the same G- measurement ID from the same web data stream.
- In GA4 go to Admin, Data collection and modification, Data streams, Web, and select the stream.
- Click Configure tag settings, then under Settings choose Configure your domains.
- Accept any domains GA4 suggests under Recommendations, or click Add condition, pick a match type (contains, exactly matches and so on), enter the domain and Save. Conditions use OR logic, and you can add up to 100.
- Test: on domain A, click a link to domain B. The landing URL should contain ?_gl=1*... and the page should load normally. Also test that file downloads still start.
- In DebugView, confirm the session continues on domain B rather than starting a new one.
What breaks it
- Redirects that drop query parameters. If domain B redirects and strips ?_gl, the link is lost. Ask developers to preserve query strings.
- JavaScript navigation. If a script moves the visitor (window.location) instead of a click on a real link or form, GA4 may not decorate the URL.
- Scripts calling stopPropagation() on clicks can stop the parameter being added.
- Consent. Cookies are only set where there is consent, so declined visitors cannot be joined across domains.
- Payment providers. A hosted payment page on a third-party domain is not yours to tag; list it as an unwanted referral instead so the return visit is not credited to the provider.
Unwanted referrals
If your own domain or a payment provider still appears as a referral source, add it under Configure tag settings, List unwanted referrals. That stops a new session being credited to it, but it does not join users across domains; only cross-domain measurement does that.
Once the journey is joined, check that campaign tags survive the hop: UTM parameters explained and the UTM builder.
Questions
- Do I need cross-domain tracking for subdomains in GA4?
- Usually not. Subdomains of the same domain share first-party cookies by default. If self-referrals appear between subdomains, Google recommends making sure every subdomain uses the same cookie domain and the same tag, and adding them to the domain list.
- What is the _gl parameter in a URL?
- _gl is the linker parameter GA4 appends to links and forms between domains you have listed, carrying the visitor's user and session identifiers so the destination domain continues the same session.
Sources
Next step
Try the utm builder
Related guides
How to set up Google Tag Manager (and GA4 through it)
Google Tag Manager set-up step by step: account and container, the two snippets, the Google tag for GA4, preview with Tag Assistant, and publishing versions.
Why GA4 numbers don't match Google Ads, Shopify or your CRM
The usual reasons GA4 disagrees with Google Ads, Shopify, Search Console and your CRM: consent, ad blockers, attribution, dates, thresholds and definitions.
UTM parameters explained (with a free UTM builder)
What the five UTM parameters do, naming rules that keep reports clean, common mistakes, and a free in-browser UTM builder.
How to set up GA4 ecommerce tracking
GA4 ecommerce tracking: the recommended events from view_item to purchase and refund, the items array, transaction_id deduplication, and how to check revenue against your store.