One of our clients created an application located on the subdomain On their main website,, they had multiple links to the application on the subdomain. Although we installed the same tracking code on both the main domain and the subdomain, Google Analytics recorded traffic for those website as traffic to two separate websites.

The problem was that the Google Analytics cookies were not shared between the main domain and the subdomain. Luckily, this problem was easy to solve: both on the main domain and the subdomain we needed to set the cookie domain to (the starting dot is very important). This way the cookies are shared between the website and the application on the subdomain.

Note: When you use one or more of the methods described below, you need to apply it to every tag used on the main domain or subdomain. If you mix cookie domains both with and without the dot, your sessions may become lost during a visit, resulting in incorrect numbers in your analytics.

If you’re using Asynchronous syntax, you can add the following line to your tracking code on both domains:

_gaq.push(['_setDomainName', '']);

If you’re using Google Tag Manager and your tag type is Classic Google Analytics, you can use the following steps:


If your tag type is Universal Analytics in Google Tag Manager, you can use the following steps:


The last thing you need to do when you’re using Universal Analytics (whether or not you’re using the Google Tag Manager), is to add referral exclusions. You can do this in the following steps:


Once you’ve completed the steps above, visits to your subdomain should be tracked the same way as visits to your main domain.

written by David Peeters