On this page
What this issue is
GA4 recognises a returning browser through a first-party cookie called _ga. It stores a client ID. A cookie is only sent to the hostname it was set for, unless its Domain attribute is a parent domain such as .example.com.
By default GA4 uses cookie_domain: auto, which picks the highest-level domain it can write to. That usually works. It breaks when the tag sets a fixed, too-narrow domain (for example www.example.com), when a theme, plugin or consent tool rewrites the cookie, or when the site sits on a public suffix such as example.co.uk and is configured by hand wrongly. The result: the _ga cookie on www and the one on shop hold different client IDs.
Why it costs you leads or sales
The visitor who clicked your Google ad, read your landing page and then moved to a booking or checkout subdomain is counted as two users. The second one often arrives with a self-referral from your own site, so the real source is lost. Conversions get credited to "direct" or to your own domain instead of the campaign that paid for the visit.
- Ad clickVisitor lands on www.example.com with campaign data
- _ga set on www onlyCookie domain is www.example.com, not .example.com
- Move to shop subdomainNo _ga cookie is sent; a new client ID is created
- PurchaseCredited to direct or self-referral, not the ad
The cookie set on www is not sent to the shop subdomain, so GA4 starts again.
Example: 100 purchases that really came from paid search. With a split cookie, many are reported as direct or self-referral.
How to check if your site has it
Open the main site
Visit your landing page in a fresh private window and accept analytics cookies if a banner appears.
Open DevToolsChrome
In Chrome press F12, go to Application, then Storage > Cookies, and select your site.
Find the _ga cookie
Look at the Domain column. A healthy value is
.example.com(leading dot). A value likewww.example.comis the problem. Also note the_ga_XXXXcookie for your measurement ID.Compare on the subdomain
Click through to your checkout, booking or app subdomain in the same window. The
_gavalue should be identical. If it changes or a second_gaappears, the users are split.Look for self-referrals
In GA4 go to Reports > Acquisition > Traffic acquisition, add Session source / medium, and look for your own domain as a source.
| Cookie domain | Meaning | Subdomains share it? |
|---|---|---|
| .example.com | Parent domain, the normal result | Yes |
| www.example.com | Single hostname only | No |
| shop.example.com | Set separately on the subdomain | No |
| Two _ga cookies | Parent and host-level cookies clash | Unreliable |
How to fix it
The fix is the same everywhere: make every GA4 tag on every subdomain use the same measurement ID and write the cookie to the shared parent domain. Where you do not need a custom value, leave cookie_domain on auto.
Open the Google tag
In Tags, open your GA4 Google tag (or GA4 Configuration tag).
Add the setting
Under Configuration settings (or Fields to Set), add
cookie_domainwith valueauto. Use your parent domain, such asexample.com, only if auto fails.Use one tag on all subdomains
Make sure every subdomain loads the same container or a tag with the same settings.
Preview and publish
Use Preview, check the cookie in DevTools, then Submit.
Edit the config call
Add
cookie_domainto the gtag config command on every subdomain, as in the code below.Remove hard-coded hostnames
Search your code for
cookieDomain,cookie_domainand_gaand remove any fixedwww.value.
Find where GA4 is added
Check your analytics plugin (for example Site Kit or a GA plugin), theme header and any tag manager plugin. Only one should add the tag.
Set the cookie domain
If the plugin has a cookie domain or advanced settings field, set
autoor your parent domain. Otherwise add the config snippet through your theme header or a tag manager.
Check how GA4 is installed
In Online Store > Preferences or the Google & YouTube app, confirm one GA4 connection. Shopify checkout may be on a different hostname from your storefront.
Use GTM if you need custom settings
The built-in connection offers limited cookie settings. If you need
cookie_domain, set it in a GTM tag as described in the Google Tag Manager tab.
Open project settings
Go to Project settings > Custom code and find your GA4 snippet.
Add cookie_domain
Add the field to the
gtag('config', ...)call and publish. Apply the same snippet to every subdomain project.
Open tracking code
Add the snippet in Sites > Funnels (or Websites) > Settings > Tracking Code, for each funnel or site on a different subdomain.
Use the same config
Paste the same measurement ID and
cookie_domainsetting in each one.
Check the connection
In Marketing & SEO > Marketing Integrations, confirm one GA4 connection. Wix manages the cookie; if the subdomain is on another platform, use that platform's steps for its tag.
Check the setup
Use Settings > Advanced > Code Injection for a custom snippet, or the Google Analytics connection, but not both. Add
cookie_domainto the custom snippet if you use it.
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
cookie_domain: 'auto'
});
// If auto does not pick the parent domain, set it explicitly:
// gtag('config', 'G-XXXXXXXXXX', { cookie_domain: 'example.com' });How to confirm it's fixed
- In a fresh private window,
_gashows the Domain.example.comon the main site. - Only one
_gacookie exists, and its value is the same on every subdomain. - In GA4 Realtime, one visit that crosses subdomains shows as one user.
- Your own domain no longer appears as a traffic source for conversions after a few days.
- The same measurement ID is used on every subdomain.
How to prevent it happening again
- Keep one documented GA4 setup and reuse it for every new subdomain.
- Leave
cookie_domainonautounless you have a proven reason to change it. - Re-check the
_gacookie domain after theme, plugin, consent tool or tag manager changes. - Add a new subdomain to your test routine the day it goes live.
- Watch for your own domain appearing in the referral report.
How FunnelGuard handles this
FunnelGuard detects this issue only partly. Its cookie matcher checks that the cookies it expects (such as _ga) are present when the robot visitor runs your journey. It does not check the cookie's domain, so it cannot tell you that _ga was set on www.example.com instead of .example.com.
To cover the rest by hand, use the DevTools check above on your landing page and on each subdomain a journey passes through, and repeat it after any tracking or theme change. FunnelGuard still helps around the edges: it runs your real journeys on a schedule, checks the GA4 hits sent at each step, and alerts you with a screenshot if a tag stops firing or a cookie goes missing. The Free plan covers 1 site and 2 journeys with daily checks and no card, and a free read-only website audit is available.
Questions people ask
Why is my GA4 _ga cookie set on www instead of the root domain?
Usually because the tag, a plugin or a consent tool sets a fixed cookie domain such as www.example.com. GA4 normally uses cookie_domain: auto, which picks the parent domain. Set it back to auto or to your parent domain and test in a fresh private window.
Why does GA4 count the same visitor as two users on my subdomain?
The _ga cookie holds the client ID. If it is stored only for one hostname, the subdomain cannot read it and GA4 creates a new ID. Writing the cookie to the shared parent domain fixes this.
How do I set cookie_domain in GA4?
Add cookie_domain to the config settings of your Google tag, either as a field in Google Tag Manager or inside gtag('config', 'G-XXXXXXXXXX', { cookie_domain: 'auto' }). Use the same setting on every subdomain.
Do I need cross-domain tracking for subdomains?
No. Subdomains of the same parent domain share cookies when the cookie domain is correct. Cross-domain measurement is only needed when you move visitors between different domains.
Why does my own website show as a referral source in GA4?
Often because a visitor moved to a subdomain that did not share the _ga cookie, so GA4 treated your main site as the referrer of a new session. Fixing the cookie domain, and checking your referral exclusion list, reduces this.
How can I check the _ga cookie domain?
Open Chrome DevTools, go to Application > Cookies, select your site and read the Domain column for _ga. A leading dot and your parent domain, like .example.com, is correct.
Does FunnelGuard detect a wrong _ga cookie domain?
Only partly. FunnelGuard's cookie matcher checks that expected cookies are present, but it does not check the cookie's domain. You need to confirm the domain by hand in your browser.
Related issues
- TRK-001GA4 tag missing from a funnel pageFix guide
- TRK-003Wrong GA4 measurement ID (staging or another client's property)Fix guide
- TRK-005Two GA4 measurement IDs sending to the same propertyFix guide
- TRK-006GA4 installed twice (gtag.js and GTM) causing double page_viewsFix guide
- TRK-014GA4 data stream web URL pointing to an old domainFix guide
- TRK-013GA4 missing on hosted checkout or booking domainFix guide