By default, Google Analytics treats subdomains as separate websites which means a user isn’t tracked across sites as the same user. Google Analytics will report two users/sessions instead of one, and you will see self-referrals in your acquisition reports i.e. users to your site from your own domain.
With some additional configuration in Google Analytics and Google Tag Manager, we can easily overcome these issues with subdomain tracking.
How to implement subdomain tracking
There are two things we need to do:
- Pass user cookie across subdomains
- Remove self-referrals
1. Pass user cookie across subdomains
We want to make sure the field name “cookieDomain” is set to “auto”.
In Google Tag Manager, if you are using a Google Analytics settings variable then check the Cookie Domain field.

If you are just using the Google Analytics pageview tag go to More Settings > Fields to Set. If you don’t see anything, simply enter “cookieDomain” into the field name and “auto” as the value.
If you are just using the Google Analytics pageview tag go to More Settings > Fields to Set. If you don’t see anything, simply enter “cookieDomain” into the field name and “auto” as the value.
Set cookieDomain to auto in GA pageview tag in GTM
2. Remove self-referrals
Inside Google Analytics, go to the admin section and then under the Property column go to Tracking Info > Referral Exclusion List and enter your domain.

Mission accomplished
Congratulations, you have successfully implemented subdomain tracking with Google Analytics and Google Tag Manager.
You have enabled the cookie client id to be passed across subdomains which means a user’s session will be stitched together and not treated separately.
You have also added your domain to GA’s Referral Exclusion List to prevent self-referrals from occurring.