
London, UK · Serving UK/EU · GBP pricing
How to set up Cross-Domain tracking in GA4.
How to set up cross-domain tracking in GA4 correctly, including GTM, payment gateways, and testing.
If your GA4 shows a spike in Direct traffic on your confirmation page, or your conversion data looks nothing like your actual sales numbers, cross-domain tracking is a likely culprit.
GA4 tracks users using a first-party cookie scoped to a single domain. When a user crosses from one domain to another, that cookie cannot follow them.
GA4 sees the arrival on the second domain as a brand new session with no source, no medium, and no campaign.
The conversion gets attributed to Direct. The original campaign that drove the visit gets no credit.
This guide explains why it happens, how to configure cross-domain tracking correctly, how to handle payment gateways and subdomains, and how to verify the setup is working.
Why GA4 loses sessions at domain boundaries.
GA4 identifies users through a first-party cookie called _ga, stored on the domain the user is visiting. When a user visits www.example.com, GA4 sets an _ga cookie on example.com and uses it to maintain session continuity and recognise returning users.
That cookie is domain-scoped. When the user navigates to a different domain, say checkout.example-payments.com, the browser does not send the _ga cookie because it belongs to a different domain. GA4 on the second domain has no way to identify this as the same user or the same session. It starts fresh.
Unless the two domains are configured to share user identity, every domain crossing is treated as a new session. For sites where the conversion happens on a different domain from the marketing site, this means virtually all conversion attribution is wrong.
When you need cross-domain tracking.
You need cross-domain tracking any time a user journey spans more than one domain and you want to measure that journey as a continuous session. Common scenarios include:
A marketing site on one domain and a checkout or booking platform on another. This is the most commercially damaging scenario because conversions are misattributed.
A third-party payment gateway such as Stripe, PayPal, or Sage Pay that processes the payment on its own domain before returning the user to your confirmation page.
A separate subdomain that is configured as a distinct domain rather than sharing a cookie with the root domain, such as shop.example.com sitting separately from www.example.com.
Multiple brand or product domains that share a single GA4 property and need unified session tracking across them.
If your user journey stays within a single domain or subdomain setup that shares a cookie, you do not need cross-domain tracking. But if there is any domain crossing in a journey that leads to a conversion, you almost certainly do.
How cross-domain tracking works in GA4.
GA4's cross-domain tracking works by appending a _gl parameter to the URL when a user clicks a link that crosses to a configured domain.
This parameter carries the user's Client ID and session information from the first domain. When GA4 on the second domain reads the _gl parameter, it picks up the existing session rather than starting a new one.
This happens automatically for links you control, once the domains are configured. The user does not see anything different.
The URL briefly contains the _gl parameter on arrival at the second domain, then GA4 reads it and the parameter disappears from the address bar.
For this to work, both domains need to have GA4 configured with the same Measurement ID, or both need to be listed in the cross-domain configuration. If only one domain is configured, the handoff will not happen.
Configuration method 1: GA4 interface.
This is the simpler method and works well for most setups.
In GA4, go to Admin → Data Streams → select your web data stream → Configure tag settings → Configure your domains.
Add every domain that should be treated as part of the same user journey. Include the domains with and without www if you are unsure how your site handles that.
For example, if your marketing site is www.example.com and your checkout is checkout.example-payments.com, add both.
GA4 uses this list to know when a link crossing should trigger the _gl parameter. Any link from a configured domain to another configured domain will automatically have the parameter appended.
Save the configuration. Changes take effect immediately for new sessions.
Configuration method 2: Google Tag Manager.
If you manage GA4 through GTM, you can configure cross-domain settings directly in the GA4 Configuration tag.
Open your GA4 Configuration tag in GTM. Under Tag Configuration, find the Fields to Set section. Add a field called linker and set it to an object containing your domain configuration.
Alternatively, in newer GTM interfaces, the GA4 Configuration tag has a dedicated cross-domain measurement section. Add each domain you want to include in the cross-domain setup.
If you configure cross-domain tracking in both the GA4 interface and GTM, they can conflict. Pick one method and stick with it. If you are using GTM, the GTM configuration takes precedence for the tags it controls.
Subdomains.
Subdomains are handled differently from separate domains, and the right approach depends on how your subdomains are configured.
If your subdomains share a root domain (for example, www.example.com and shop.example.com), you can configure GA4 to use a cookie scoped to the root domain rather than the subdomain. In GTM, in your GA4 Configuration tag, go to Fields to Set and add cookie_domain with a value of example.com.
This tells GA4 to set the _ga cookie on the root domain, which is accessible from all subdomains, so sessions flow naturally across them without needing cross-domain tracking.
If your subdomains behave as separate domains (different servers, different GA4 properties, or different cookie configurations), treat them the same as separate domains and add them to the cross-domain list.
When in doubt, test. Check whether the _ga cookie set on your main domain is visible when you navigate to the subdomain. If it is, you likely do not need cross-domain configuration for that subdomain. If it is not, add the subdomain to the cross-domain list.
Referral exclusions: what they are and how they differ.
Referral exclusions are commonly confused with cross-domain tracking but they serve a different purpose.
When GA4 receives a session with a referrer from a domain listed in your referral exclusions, it does not start a new session. It treats the referral as if it came from within the same site.
This is useful when a third-party domain is part of your own user journey, such as a payment gateway, and you do not want a return visit from it to overwrite the original campaign attribution.
Cross-domain tracking and referral exclusions often need to be configured together.
Cross-domain tracking handles the outbound journey, ensuring the _gl parameter is passed when the user leaves your domain.
Referral exclusions handle the return journey, ensuring GA4 does not start a new session when the user comes back from the gateway.
A common mistake: adding your own domain to the referral exclusions list instead of the cross-domain list.
Your own domain should never be in referral exclusions. If example.com is in your referral exclusions, GA4 will suppress sessions that appear to come from your own domain, which can cause other attribution problems.
Your own domains go in the cross-domain list. Third-party domains that form part of your journey, like payment gateways you return from, go in the referral exclusions list.
To add referral exclusions: Admin → Data Streams → select your stream → Configure tag settings → List unwanted referrals.
Testing the setup.
Do not assume cross-domain tracking is working just because it is configured. Test it explicitly before relying on the data.
Step 1: Open GA4 DebugView (Admin → DebugView) and enable debug mode in GTM or via the GA4 Tag Assistant Chrome extension.
Step 2: Navigate from your main domain to the second domain by clicking a real link on the page, not by typing the URL directly.
Step 3: In DebugView, check whether the Client ID is consistent across both domains. You can see this in the event parameters on the session_start event. If the Client ID on the second domain matches the Client ID on the first domain, the handoff worked. If it is different, the _gl parameter was not passed or was not read correctly.
Step 4: After completing a test conversion, check GA4 → Reports → Traffic Acquisition and look at the source attributed to the conversion. If it shows the original traffic source rather than Direct, cross-domain tracking is working end-to-end.
Step 5: Check the Direct traffic share on your confirmation page specifically. In GA4 Explorations, filter to sessions that included the confirmation page as a landing page and look at the source breakdown. If Direct is still dominant, something in the handoff is not working and the diagnostic steps above apply.
Common mistakes.
Not listing all domains. If a domain is missing from the cross-domain list, GA4 will not append _gl to links going to that domain. Every domain in the user journey needs to be listed, including any intermediary redirect domains.
Mixing GTM and GA4 interface configuration. Configuring cross-domain in both places can cause conflicts. Use one method consistently.
Assuming subdomains need cross-domain configuration. Subdomains sharing a root domain usually just need the cookie_domain field set correctly. Adding them to the cross-domain list as well can sometimes cause duplicate parameter appending.
Not adding the payment gateway to referral exclusions. Even if cross-domain tracking is working outbound, if the gateway is not in referral exclusions, GA4 may start a new session when the user returns from the gateway, overwriting the original attribution.
Testing only in GTM Preview mode. GTM Preview operates differently from live browsing and may not accurately reflect how cross-domain parameter passing behaves in the real user journey. Always test on the live published site using GA4 DebugView.
iFrame payment steps. If the payment step is embedded as an iFrame within your own page rather than a full domain redirect, cross-domain tracking configuration will not help. iFrames do not trigger GA4's link decoration. This requires a different approach, typically server-side tracking.
Setup checklist.
Work through these in order before considering the setup complete.
Identify every domain in the user journey that needs to share session data.
Add all domains to the cross-domain list in GA4 or GTM, using one method consistently.
If subdomains are involved, set cookie_domain to the root domain in the GA4 Configuration tag.
Add any third-party return domains, such as payment gateways, to the referral exclusions list.
Test the _gl parameter by clicking through the domain crossing on the live site and checking it arrives on the destination page.
Verify Client ID consistency across domains using GA4 DebugView.
Check Direct traffic on the confirmation page in GA4 Explorations to confirm conversion attribution is correct.
If a payment gateway strips _gl, investigate whether a custom return URL, server-side tracking, or a first-party data approach is the right solution.
Summary.
Cross-domain tracking is one of the most commercially significant GA4 configurations to get right.
If your conversions happen on a different domain from your marketing site and cross-domain tracking is not configured, virtually all your conversion attribution is wrong. Direct gets the credit. Your actual campaigns get none.
The configuration itself is straightforward: list every domain in the user journey, use one configuration method consistently, add payment gateways to referral exclusions, and test on the live site rather than in preview.
The complications arise at payment gateways that strip query parameters on return, which require either a server-side solution or a direct coordination with the gateway.
Test everything before relying on the data. The DebugView Client ID check takes five minutes and tells you definitively whether the session handoff is working.
Related services
-
38-Point GA4 Audit — Comprehensive review of your current setup
-
Expert GA4 Setup — Clean implementation from scratch
-
GA4 Training — Empower your team to use GA4 confidently
-
Connect GA4 to BigQuery — Unlock advanced analysis and data warehousing