Track users across subdomains with Google Analytics and Google Tag Manager (GTM)

ChrisGoogle AnalyticsLeave a Comment

Google Analytics subdomain tracking

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:

  1. Pass user cookie across subdomains
  2. 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.

Setting cookieDomain in GA settings variable in GTM
Set cookieDomain to auto in GA settings variable in GTM

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.

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.

Updating GA Referral Exclusion List
Update GA Referral Exclusion List

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.

Get Free Email Updates

Signup now and receive an email once I publish new content.

I will never give away, trade or sell your email address. You can unsubscribe at any time.