Skip to content

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.

Even though subdomain tracking works by default, three things can break it:

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.

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.

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.

  1. Open your browser DevTools on www.example.com
  2. In the Application tab → Cookies → find _ga
  3. Note the Domain column — it should show .example.com (with leading dot), not www.example.com
  4. Note the Value — e.g., GA1.1.123456789.1616000000
  5. Navigate to shop.example.com
  6. Check Cookies again — the _ga cookie should have the same value
  7. 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.

  1. Visit www.example.com in a browser where you have never been before (or clear cookies)
  2. In DevTools → Application → Cookies, note the _ga value and its domain (.example.com)
  3. Click a link to shop.example.com
  4. Check that the _ga cookie value is identical and the domain is still .example.com
  5. Confirm in GA4 DebugView that you are still in the same session

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.