GA4 tracks subdomains of the same root domain automatically: put the same Google tag on blog.site.com and shop.site.com and they share one user and one session. Separate domains need cross-domain tracking: add every domain under Admin → Data streams → Configure tag settings → Configure your domains, and the Google tag passes the user’s identity between them with the _gl parameter.
This guide shows both setups step by step (GA4 admin, Google Tag Manager and gtag.js), how to test them, what the _gl parameter does to SEO and UX, and how to fix the usual problems: sessions that restart, self-referrals and payment pages.
Cross-Domain vs. Subdomain Tracking: What’s the Difference?
Subdomain tracking follows users across subdomains of the same root domain, such as www.site.com, blog.site.com and store.site.com. The Google tag stores the _ga cookie on the root domain (site.com) by default, so every subdomain reads the same client ID. No configuration is needed.
Cross-domain tracking follows users across different domains, such as shop.com and checkout-shop.com. Cookies cannot be shared between domains, so without configuration the second domain creates a new client ID: one visit becomes two users, two sessions, and a referral from your own site.
- Tracking: SubdomainAutomaticExample: blog.site.com → store.site.comWhat it needs: Works within the same root domain, minimal configuration
- Tracking: Cross-domainManualExample: shopping.com → payment.comWhat it needs: Separate domains, special configuration needed
| Tracking | Example | What it needs | Setup |
|---|---|---|---|
| Subdomain | blog.site.com → store.site.com | Works within the same root domain, minimal configuration | Automatic |
| Cross-domain | shopping.com → payment.com | Separate domains, special configuration needed | Manual |
Typical cross-domain cases: a checkout or booking engine on its own domain, several country domains (site.de, site.fr) that share one funnel, or a marketing site and an app on different domains.
Before You Start: One Property, One Web Stream
- Map your domains: List every domain and subdomain users move between, and mark where conversions happen (checkout, booking, sign-up).
- Use one GA4 property for all domains that belong to the same user journey. Separate properties only make sense for separate businesses; journeys between properties cannot be stitched.
- Use one web data stream for the site, not one stream per domain or subdomain. Several web streams in one property for the same site split and duplicate data.
- Use the same Measurement ID (G-XXXXXXXXXX) on every page of every domain, through gtag.js or the Google tag in Google Tag Manager.
How to Set Up Subdomain Tracking in GA4
In most cases, subdomain tracking in GA4 is already working once the same Google tag is on every subdomain. The checklist:
- Install the same Measurement ID on all subdomains, including checkout, blog, help center and landing page tools.
- Don’t override cookie_domain in your tag settings; the default (auto) stores the cookie on the root domain.
- You don’t need to add subdomains under Configure your domains. Adding the root domain does no harm.
- If a subdomain runs on another platform (for example a HubSpot landing page or a hosted shop), install the same tag there too.
If blog.site.com shows up as a referral to www.site.com, a page is usually missing the tag or uses a different Measurement ID. Fix the tag first; hiding the referral only hides the gap.
To see which subdomain a page belongs to in reports, add the Hostname dimension (for example in Explore, or as a secondary dimension in Pages and screens).
How to Set Up Cross-Domain Tracking in GA4
Cross-domain tracking is configured once, in the GA4 admin, and works for both gtag.js and Google Tag Manager. Google documents the steps in its cross-domain measurement help article.
- Make sure the same Google tag (same Measurement ID) is installed on every domain.
- In GA4, go to Admin → Data collection and modification → Data streams and open your web stream.
- Click Configure tag settings, then Configure your domains.
- Add each domain with a match type, for example “Ends with” shop.com and “Ends with” checkout-shop.com, and save.
- Test the setup (see the testing section below). Changes can take a short while to apply.
After this, the Google tag automatically adds the _gl parameter to links and forms that point to the listed domains, and the receiving domain reads it to keep the same client ID and session.
Cross-Domain Tracking with Google Tag Manager
In GTM, GA4 runs through the Google tag (formerly the “GA4 Configuration” tag). Once your domains are listed in the GA4 admin, the Google tag picks up that setting; you don’t need to add a linker field in GTM. Older guides that tell you to set a “linker” field in Fields to Set describe the setup from before this admin setting existed.
- Make sure the Google tag with your Measurement ID fires on All Pages in every container used on your domains.
- If two domains use different GTM containers, both must load the Google tag with the same Measurement ID.
- Configure the domain list in GA4 admin as above, then test in GTM Preview (Tag Assistant).
Cross-Domain Tracking with gtag.js Code
If you prefer to keep the domain list in code, or cannot use the admin setting, you can configure the linker in gtag.js directly. Put the same snippet on every domain:
<!-- Google tag (gtag.js): same Measurement ID on every domain -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
linker: {
domains: ['shop.com', 'checkout-shop.com']
}
});
</script>- Replace G-XXXXXXXXXX with your Measurement ID.
- List all domains in the domains array, on every domain.
- Use either the admin setting or the code, not two different lists; keep them identical if you use both.
How to Test Cross-Domain and Subdomain Tracking
- Tag Assistant: Open tagassistant.google.com (or GTM Preview), start on domain A and click a link to domain B. The URL on domain B should contain _gl, and the Google tag should fire on both domains.
- Client ID check: In your browser’s developer tools (Application → Cookies), compare the _ga cookie on both domains. The number after GA1.1. must be the same.
- DebugView: In GA4 Admin → DebugView, your page_view events from both domains should appear under one device, in one session.
- Referral check: After a few days, look at Traffic acquisition by session source. Your own domains should not appear as referral sources.
Realtime reports aggregate data and can’t show whether two page views belong to one session. DebugView and the client ID check can.
The _gl Parameter: What It Is, SEO and UX
When a user clicks from one listed domain to another, the Google tag appends a linker parameter to the URL:
https://checkout-shop.com/cart?_gl=1*1abc2de*_ga*MTIzNDU2Nzg5LjE3MDAwMDAwMDA.*_ga_XXXXXXXXXX*MTcwMDAwMDAwMC4xLjEuMTcwMDAwMDA1MC4wIt carries the client ID and session information. The value is only valid for a short time (about two minutes), so a copied or bookmarked URL with an old _gl value does not link sessions.
Does _gl Hurt SEO?
No, in normal use. _gl is only added to links users click between your own domains; search engines rarely discover these URLs. Make sure every page has a self-referencing canonical tag so any parameter version points to the clean URL:
<link rel="canonical" href="https://checkout-shop.com/cart" />Don’t block _gl URLs in robots.txt: blocked URLs can’t be crawled, so search engines can’t see their canonical tag. Search Console’s old URL Parameters tool, which some guides still mention, was retired by Google in 2022.
_gl and User Experience
The parameter makes URLs longer and less pleasant to share. If you remove it with JavaScript, do it only after the Google tag has loaded and read it, otherwise the link between domains breaks. In most cases the safest choice is to leave it.
One practical problem: some form and CRM tools save the full page URL into a field, and a long _gl value can exceed its limit (errors like “fields exceed maximum length: _gl”). Save the URL without its query string, or only the parameters you need.
GA4 Cross-Domain Tracking Troubleshooting
Sessions Restart When Users Switch Domains
- A domain is missing from Configure your domains, or the match type doesn’t cover it (www vs. non-www).
- A redirect between the domains drops the query string, so _gl never arrives. Keep query parameters on redirects.
- The navigation happens in JavaScript (window.location, a button handler) instead of a link or form, so the tag can’t decorate it. Use a real link or add the linker manually.
- The user declined cookies on one domain. With Consent Mode, no _ga cookie is set, so there is no client ID to pass.
Self-Referrals in GA4 Reports
If your own domains appear as referral sources: check that every domain is listed under Configure your domains and that every page has the tag. Listed domains are automatically treated as internal, so you don’t need to add them to the unwanted referrals list as well.
Third-Party Payment Pages (PayPal, Stripe, iyzico)
When users go to a payment provider and come back, the return visit is attributed to that provider unless you exclude it. Go to Configure tag settings → Show more → List unwanted referrals and add the provider’s domains. If you can’t place your tag on the payment page, track the purchase on your own confirmation page or server side.
Missing or Incorrect Data
Check that the tag fires on every page in Tag Assistant, that all domains use the same Measurement ID, and that consent banners load before the tag. A second, older tag (for example a hard-coded gtag.js plus GTM) can send duplicate page views.
Privacy and Consent
Cross-domain tracking passes a pseudonymous identifier between your domains, so it falls under the same consent rules as the rest of GA4. In the EEA and the UK, load GA4 through a consent management platform with Google Consent Mode v2; Google requires Consent Mode for ads personalization and measurement features for EEA users. GA4 does not log or store IP addresses, and you can set the data retention period under Admin → Data collection and modification → Data retention.
GA4 Cross-Domain Setup Checklist
- Control step: GA4 tracking codes and GTM tagsMonthly
- Control step: Cross-domain and subdomain transitionsEvery 3 months
- Control step: Self-referral error checksEvery 3 months
- Control step: Conversion and event trackingMonthly
- Control step: Data accuracy tests (DebugView & Real-Time)Monthly
| Control step | Frequency |
|---|---|
| GA4 tracking codes and GTM tags | Monthly |
| Cross-domain and subdomain transitions | Every 3 months |
| Self-referral error checks | Every 3 months |
| Conversion and event tracking | Monthly |
| Data accuracy tests (DebugView & Real-Time) | Monthly |
Conclusion
Subdomains take care of themselves once the same tag is everywhere. Separate domains need one admin setting and a test: list the domains, check that _gl arrives and the client ID matches, and exclude payment providers. Get these right, and your funnel, attribution and conversion data describe one user journey instead of several broken ones.
GA4 Cross-Domain Tracking: Frequently Asked Questions
Does GA4 track subdomains automatically?
Yes. If every subdomain uses the same Measurement ID and you don’t override the cookie domain, GA4 stores the _ga cookie on the root domain and treats all subdomains as one site. No cross-domain setup is needed.
To track users and sessions across multiple domains, what must be set up first?
The same Google tag (the same Measurement ID) has to be installed on every domain. Then you configure cross-domain measurement by listing the domains under Configure your domains in the web data stream.
What happens when the same default tracking code is installed on different domains?
Each domain sets its own first-party cookie, so the same person gets a different client ID on each domain. One visit is counted as two users and two sessions, and the second domain shows the first as a referral, until cross-domain tracking is configured.
Do I need to set the linker in Google Tag Manager?
No. With the Google tag in GTM, the domain list you configure in the GA4 admin applies automatically. Setting a linker field in GTM is an older method; if you use it, keep the list identical to the admin setting.
What is the _gl parameter in my URL?
_gl is GA4’s linker parameter. The Google tag adds it to links between your listed domains so the destination can keep the same client ID and session. It is only valid for a short time and does not affect SEO when pages have canonical tags.
Should I use one GA4 property or several for multiple domains?
Use one property with one web data stream when the domains are part of the same user journey, such as a site and its checkout. Use separate properties only for separate businesses whose users you never need to follow between sites.
Why do my own domains appear as referrals in GA4?
Usually because a domain is missing from Configure your domains, some pages have no tag, or a redirect drops the _gl parameter. Fix the setup first; listing your own domains as unwanted referrals only hides the symptom.
- GA4
- Google Analytics
- Google Tag Manager
