GA4 Cross-Domain Tracking: Setup, the _gl Parameter, and How to Test It
When visitors move from your marketing site to a checkout or booking domain, GA4 splits them into two users and credits your own site as the referrer. This guide explains when you need cross-domain measurement, how the _gl linker works, how to set it up, and how to prove it works.
In short
GA4 cross-domain measurement keeps one user and one session when visitors move between domains you own. Add each domain under the web stream's Configure your domains setting, and the Google tag appends a _gl parameter carrying the client and session IDs to links and forms between them. Test it by checking that _gl appears on the destination URL.
Your marketing site is on one domain and your checkout, booking tool or app sign-up is on another. In GA4, your own domain shows up as a top referrer, purchases are credited to referral instead of the campaign that brought the visitor, and the user count looks too high. That is what happens without cross-domain measurement: GA4 sees the second domain as a new visitor arriving from the first. This guide explains when you need cross-domain tracking, how the _gl parameter works, how to configure it, and how to test it before you trust the numbers.
Do you need it? A quick test
Open Traffic acquisition, set the primary dimension to Session source, and look for your own domains among the referrers. If example.com appears as a source of sessions on your property, visitors are crossing a boundary that GA4 treats as a new visit. A second sign is a purchase or sign-up report where referral from your own site is a top channel. A third is a user count noticeably higher than your backend's count of unique customers for journeys that span two domains. Any of the three means the setup below is worth doing. If none applies, for example because your whole journey runs on one domain, you do not need cross-domain measurement at all.
Why GA4 splits visits across domains
GA4 identifies a browser through a first-party cookie (_ga) that holds the client ID, plus a session cookie for the session. Cookies belong to a domain. When a visitor goes from example.com to example-checkout.com, the second domain cannot read the first domain's cookies, so the Google tag there creates a new client ID and a new session. The new session's traffic source is the referrer, example.com, and the campaign that brought the visitor is lost at exactly the point they convert.
How the _gl parameter fixes it
With cross-domain measurement configured, the Google tag watches for clicks on links and submissions of forms that point to another configured domain. When it sees one, it appends a _gl parameter to the destination URL, for example ?_gl=1*abcde5*... The value carries the client ID and session information. The Google tag on the destination reads _gl and uses those IDs instead of creating new ones, so Analytics counts one user and one session. GA4 also excludes traffic that arrives with the linker parameter from being treated as a referral.
Setting it up step by step
- 1Install the same Google tag (the same measurement ID, sending to the same GA4 property) on every domain in the journey. Cross-domain measurement cannot join data from separate properties.
- 2In GA4, go to Admin, Data collection and modification, Data streams, select the web stream, then Configure tag settings, and under Settings choose Configure your domains. You need the Editor role or above.
- 3Accept any domains GA4 lists under Recommendations, or click Add condition and enter each domain with a match type, for example contains example-checkout.com. Google allows up to 100 conditions, evaluated with OR logic.
- 4Include every domain in the journey, including the one you start on.
- 5Save. The change applies to the Google tag automatically; there is nothing to publish in the GA4 interface. If you load the tag through Google Tag Manager, no extra configuration is needed for the standard setup.
Subdomains of the same root domain usually share the _ga cookie automatically, because the Google tag sets it at the root by default. Google recommends cross-domain configuration for subdomains when they use different cookie domains, since that is a common source of self-referrals. Use one consistent cookie_prefix across all domains; different prefixes create separate cookies and break the link.
How to test it
Google's own test is simple, and worth doing on every journey, not just one link:
- 1Open the first domain in a private window, ideally with a tagged campaign URL so you can see the source survive.
- 2Click a link, or submit a form, that leads to the other domain.
- 3Confirm the destination page loads correctly and that its URL contains _gl.
- 4If the site offers downloads through the second domain, confirm they still start.
- 5In GA4 DebugView, with debug mode on, confirm that events on both domains appear under the same device and that the second domain did not fire a new session_start with your own domain as the source.
After a day, check the referral report: your own domains should drop out of the top referrers for new data. Older sessions are not rewritten, so compare periods that start after the change. Also expect user counts on the second domain to fall slightly, since visitors who were counted twice are now counted once. Our guide to testing tracking with GA4 DebugView covers debug mode in detail.
Why cross-domain tracking breaks
- A redirect strips the query string. If the destination redirects (to add a trailing slash, a locale or www) and drops unknown parameters, _gl is lost. Google's advice is to configure the site to preserve _gl through redirects. This is the same failure that drops UTMs, covered in UTM parameters not showing in GA4.
- Navigation by JavaScript. The tag decorates real links and form submissions. Buttons that navigate with window.location, or scripts that call stopPropagation on the click, can prevent _gl from being added. Decorate those URLs yourself or change them to plain links.
- The destination domain is missing from the list, or the tag on it is a different measurement ID.
- Embedded content. A booking widget or form in an iframe from another domain is not a navigation, so _gl is not involved; see tracking embedded forms and iframes for the options.
- Inconsistent consent setups. If each domain runs its own banner with different defaults, test the journey with consent granted and with it declined, because the tag on the destination behaves according to that domain's consent state.
Cross-domain measurement vs unwanted referrals
The two settings sit next to each other in the tag settings and are often confused. Cross-domain measurement is for domains you own and tag: it joins the session. The unwanted referrals list is for domains you do not tag, such as a payment provider: it stops them from becoming the traffic source when the visitor returns, but it does not join anything. For PayPal, Stripe and similar hosted pages, see fixing payment gateway referrals in GA4.
Keeping attribution intact beyond GA4
Cross-domain measurement fixes GA4, but the same domain hop also loses campaign data for every other tool that relies on cookies. Capturing UTMs and click IDs on the first landing and carrying them with the visitor, or passing them in the URL to the second domain, keeps the context for your CRM and ad platforms too. Our tracking audit checks whether parameters survive a page's links and redirects, which is a quick way to find the hops that break.
Frequently asked questions
Do I need cross-domain tracking for subdomains in GA4?
Usually not, if every subdomain uses the same Google tag and the cookie is set on the root domain, which is the default. Google recommends configuring it for subdomains when they use different cookie domains, since that can cause self-referrals. If shop.example.com shows example.com as a referrer, set it up.
Does cross-domain tracking work with a third-party checkout I do not control?
Only if that domain runs your GA4 tag or you can add it. Hosted payment pages from providers such as PayPal or Stripe do not, so there is nothing to link. For those, list the provider as an unwanted referral so the return visit does not take credit for the sale.
Why does the _gl parameter disappear from my URL?
The destination site removed it, usually through a redirect that rebuilds the URL without query parameters, or a single-page app that rewrites the URL before the tag reads it. Google's documentation says to configure the site to keep _gl through redirects.
Do both domains need to be in the same GA4 property?
Yes. Cross-domain measurement links the client and session IDs within one data stream's configuration, so both domains should send data to the same property using the same Google tag. Separate properties will always count separate users.
Sources
Try EndFrame
Add a server-side path for your conversions.
EndFrame collects events first-party and forwards conversions server-side to Meta, GA4, TikTok, and webhooks with event-ID deduplication — then credits each conversion to its campaign, with the visit-to-conversion path you can audit.
No credit card required