Recently I am investigating how to track user behaviors across our digital services.
We have web applications like:
- example.com (the company homepage)
- service-A.example.com (digital service A)
- 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:
- Use Universal Analytics
- In tag settings of GTM, set cookieDomain‘s value to auto
- In Referral Exclusion List of GA, add example.com
- Done
For trouble shooting, I recommend to install Google Analytics Debugger (A chrome extension).
To test it, you can
- 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“ - 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” - 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.