Subdomain Tracking
Subdomains of the same root domain — shop.example.com, blog.example.com, app.example.com — do not require cross-domain tracking. GA4’s default cookie configuration handles them correctly without any extra setup. But there are a few things to verify, and a few edge cases that can still break sessions.
Why subdomains work differently from cross-domain
Section titled “Why subdomains work differently from cross-domain”GA4 sets its _ga cookie with the domain set to the root domain (e.g., .example.com with a leading dot). This makes the cookie accessible to all subdomains of example.com. When a user navigates from www.example.com to shop.example.com, the browser sends the same _ga cookie, GA4 reads the same Client ID, and the session continues.
No _gl parameter is needed. No domain list configuration is required. It just works.
What you need to verify
Section titled “What you need to verify”Even though subdomain tracking works by default, three things can break it:
1. Cookie domain configuration
Section titled “1. Cookie domain configuration”GA4 via the Google Tag sets cookie_domain to auto by default, which resolves to the root domain. If someone has manually set cookie_domain to the full subdomain hostname (e.g., shop.example.com), the cookie will only be accessible on that specific subdomain.
Check this in GTM:
Open your Google Tag configuration and look for cookie_domain in the configuration fields. It should be auto or the root domain .example.com.
If it is set to the full hostname, remove the override and let GA4 use auto.
2. Referral exclusions
Section titled “2. Referral exclusions”When a user navigates from shop.example.com back to www.example.com, GA4 might count shop.example.com as a referral source if it is not excluded. Check your referral exclusion list:
GA4 → Admin → Data Streams → [your stream] → Configure tag settings → List unwanted referrals
Add example.com (or the specific subdomains you use) to prevent them from being counted as referral traffic.
3. Separate GTM containers per subdomain
Section titled “3. Separate GTM containers per subdomain”If different subdomains use different GTM containers, verify both containers reference the same GA4 Measurement ID. If they use different Measurement IDs, you have two separate GA4 properties and sessions will not be connected.
Verifying subdomain tracking works
Section titled “Verifying subdomain tracking works”- Open your browser DevTools on
www.example.com - In the Application tab → Cookies → find
_ga - Note the Domain column — it should show
.example.com(with leading dot), notwww.example.com - Note the Value — e.g.,
GA1.1.123456789.1616000000 - Navigate to
shop.example.com - Check Cookies again — the
_gacookie should have the same value - In GA4 DebugView, verify the session continues (same
ga_session_id) without a new session starting
If the _ga value changes between subdomains, cookie domain is misconfigured. If a new session starts despite the same _ga value, check referral exclusions.
What to do if you have a separate GA4 property per subdomain
Section titled “What to do if you have a separate GA4 property per subdomain”Some organisations intentionally use separate GA4 properties for different subdomains (e.g., the main marketing site and the app use different properties for separate analysis). This is a valid architecture, but it means:
- Sessions are independent across properties — no cross-subdomain attribution
- User counts will overlap (same user counted in both properties)
- You cannot create an audience that spans both subdomains in a single property
If you want unified analysis across subdomains AND separate views per subdomain, use one GA4 property with GA4 Audiences filtered by Page Hostname to segment the data.
Test it
Section titled “Test it”- Visit
www.example.comin a browser where you have never been before (or clear cookies) - In DevTools → Application → Cookies, note the
_gavalue and its domain (.example.com) - Click a link to
shop.example.com - Check that the
_gacookie value is identical and the domain is still.example.com - Confirm in GA4 DebugView that you are still in the same session
Common gotchas
Section titled “Common gotchas”www. is treated as a subdomain too. Your root domain cookie must be set to .example.com (not www.example.com) for it to work on all subdomains including shop.example.com.
Third-party hosted subdomains. If shop.example.com is hosted on Shopify or another platform, the cookie configuration is controlled by that platform’s GTM installation. The domain may be correct, but you need to verify the platform actually sets cookies on the root domain. Shopify, for example, has its own first-party tracking and may handle this differently.
Mixed secure and non-secure subdomains. If one subdomain is HTTPS and another is HTTP, the Secure flag on the GA4 cookie may prevent it from being sent on the HTTP subdomain. Always use HTTPS across all subdomains.