No! Basic Google Analytics Tracking on Your Sub-Domain is Not OK

Big No-No

Widespread access and ease of use, not to mention lack of price tag, have made Google Analytics ubiquitous on modern commercial websites.  It’s easy to get up and running, fun to watch the data come in, and has the look of very sophisticated software.  But what many companies are failing to realize, is that anything beyond a simple website will likely require modifications in order to ensure accurate, relevant data and to get the most out of Google Analytics.  For example, one issue that has come up with a few clients recently is the use of basic Google Analytics Tracking Code on a main domain ( as well as several sub-domains (,,…).  This is a big ‘NO-NO’.

Why It’s Not a Good Idea

The problem is that using the plain vanilla tracking code will lead to data distortions.  This is because, by default, Google Analytics considers a domain to be a separate entity from a sub-domain.  A visitor that moves from a domain to a sub-domain will be: a) counted twice and b) identified in the ‘referring sites’ report as coming from your domain – neither of which are particularly helpful.  The situation is further complicated if the visitor goes back from the sub-domain to the main domain.


The 14,000 visits indicated from ‘’ are actually visits from the main domain to the sub-domain – i.e. double-counting of visits to the site.  Here how the data breaks down in the above scenario:

* Google Analytics will keep track of all the referrals used in a session (through multiple trips in and out of the site, all within 30 minutes of the next), but it will only attribute the visit to the first one in the session.  Subsequent referrals will be assigned to ‘0’ visits. See an example of multiple referral tracking here.

What To Do About It

Since this is a fairly common situation, Google has provided an easily implementable solution for sub-domain tracking that results in your domain and sub-domain being considered all part of the same site. All it takes is one line added to the GA tracking code:

GATC-subdomainThe addition of this modification tells Google Analytics that any sites within the domain identified (‘’ in this case) should be considered as one. No duplicate counting, no self-referring. Done.

Note that in addition to the small change to the tracking code, Google also provides information on a filter that can be implemented to identify the domain or sub-domain of a given page in content reports.

Key things to remember:

1. This same code should go on ALL your pages of your main domain and any sub-domains you are tracking.

2. If you use the same file names for pages on your main domain ( and sub-domain (, apply the recommended filter to distinguish them in your content reports.

3. If your site has been running for a while and has accumulated a significant number of duplicate visit counts due to traffic between the main domain and sub-domain, be prepared for lower traffic numbers under the new tracking.  It may be necessary to explain to your boss that this does not mean that actual traffic has dropped off, but that it was artificially over-inflated previously.  (Unfortunately, old data can not be retroactively adjusted.)

What If  I Want to Track My Domain and Sub-Domains Separately?

GA-Profile-New-DomainIn some cases, you may consider your sub-domain to be a different site than your main domain and you may want to track them separately. That’s cool. It just means that you should set up a separate profile for the sub-domain using the ‘Add a Profile for a new Domain‘ option.   This method will provide you with a new UA number that will be used in the tracking code to differentiate the sub-domain profile from the main domain.  They will then be tracked as independent sites.

Now you know what to do to make sure Google Analytics is set up to track domain and sub-domain traffic in the way that best suits your needs.