Tracking subdomains with Google Tag Manager

Recently I am investigating how to track user behaviors across our digital services.

We have web applications like:

  1. example.com (the company homepage)
  2. service-A.example.com (digital service A)
  3. service-B.example.com (digital service B)

and we are using Google Tag Manager (and Google Analytics)

To be straight forward, what we need are:

  1. Use Universal Analytics
  2. In tag settings of GTM, set cookieDomain‘s value to auto
  3. In Referral Exclusion List of GA, add example.com
  4. Done

For trouble shooting, I recommend to install Google Analytics Debugger (A chrome extension).

To test it, you can

  1. go to example.com
    Use GA debugger to find the GA clientId, e.g. 1753731437.1492367410, and
    It has a cookie _ga with value “GA1.2.1753731437.1492367410“, and the domain is: “.example.com
  2. Click a link to navigate to service-A.example.com
    The GA clientID on Service A should be the same, and
    It has an identical _ga cookie: same value, same domain “.example.com”
  3. Directly type URL service-B.example.com
    Again, the same GA clientID and _ga cookie

There some some great articles about this topic. The most useful posts that I found are from lunametrics (cross-domain tracking and sub-domain tracking with a great diagram), and from Simo Ahava (here and here) with deep core code explanation. A post from e-nor is also useful.

Share Comments