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 (www.site.com) as well as several sub-domains (blog.site.com, support.site.com, shopping.site.com…).  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.

GA-self-referral

The 14,000 visits indicated from ‘xyz-software.com’ 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:

GA-subdomain-dblcounting
* 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 (‘.example.com’ 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 (www.yoursite.com/index.htm) and sub-domain (blog.yoursite.com/index.htm), 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.

Advertisements

14 Responses

  1. Hi John,

    We’re also experiencing similar issues, but I don’t think that what you have here solves the issue of self referring, seems to me that clicks on any links on the subdomain mean that the domain becomes the referrer as the original referring information is overwritten.

    There are a couple of other solutions about for this, including this one from Google http://services.google.com/analytics/breeze/en/domains_subdomains/index.html which might work.

    Shane

  2. Good post, John. But, along with your note about how GA measures referrals, we need to also look at how they use the same 30 minute window for visits.

    “If a user is inactive on your site for 30 minutes or more, any future activity will be attributed to a new session. Users that leave your site and return within 30 minutes will be counted as part of the original session.”

    So, if a visitor were to go to “www.yoursite.com” then toggle to the subdomain “products.yoursite.com” and return to “www.yoursite.com” before the 30 minute visit time-out it shouldn’t increase the total visits.

    • Good point, Jared. Under your scenario total visits won’t be increased, but the subdomain will still be recorded as a referral, which will skew site stats on the original referrer.

      So my table with the visit count assumes greater than 30 minutes on the subdomain before returning to the main site. I tried to explain below the table that visits wouldn’t increase within the 30 minute window, but maybe didn’t make that as clear as I could have.

      Thanks for your comment!

  3. Grateful for your post……I’ve been searching for hours for the answer to this question…..couldn’t find it as clearly articulated anywhere (including wordpress or GA forums). Thank you.

    • Theresa,

      Glad I could be of assistance! Let me know if you encounter any problems and I will help if I can.

      John

  4. Hi there, I’ve set up subdomain and domain tracking for a client of ours on domain.com and sub.domain.com using the following code.

    _gaq.push([‘_setAccount’, ‘UA-119583xx-1’]);
    _gaq.push([‘_setDomainName’, ‘.domain.com’]);
    _gaq.push([‘_setAllowLinker’, true]);
    _gaq.push([‘_setAllowHash’, false]);
    _gaq.push([‘_trackPageview’]);

    I’ve looked at navigation summary next page reports from sub.domain to domain.com and advanced filters that contain only sub.domain visits. This captures page level data, but not visitor/unique visitor data. How would I go about seeing accurate visitor referrals from sub.domain to domain.com and domain.com to sub.domain.com if they both utilize the same tag above?

    Thank you!
    Ryan

    • Hi Ryan,

      First of all, thanks for posting an example of doing this using the new GA async code!

      The whole point of setting up combined domain/subdomain tracking is so that all traffic is counted together, and there are no ‘internal’ referrals. Basically, you’ve taken ‘referrals’ in this sense out of the equation, so the only option you’d have – that I can think of – is to go by navigation paths, as you mention. But, as you point out, by the nature of this data, it has the limitation of being at the only page level.

      I think you have to decide what is more important: to have all your traffic on the domain and subdomain counted together, or count them separately and track interactions. If the latter is the case, then you are better off NOT to add the _setDomainName.

      Hope this helps!?

      John

  5. Have you ever considered writing an ebook or guest authoring on
    other sites? I have a blog based upon on the same
    topics you discuss and would really like to have you share some stories/information.

    I know my readers would value your work. If you are even remotely interested, feel
    free to shoot me an e mail.

  6. Sweet blog! I found it while searching on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!
    Appreciate it

  7. At this time I am going away to do my breakfast, once having my breakfast
    coming again to read additional news.

  8. hi!,I really like your writing very much! proportion we communicate
    more approximately your post on AOL? I require an expert in this space to solve
    my problem. Maybe that’syou! Having a look ahead tto see you.

  9. Thanks for sharing your thoughts about addmefast points hack.
    Regards

  10. Its like you read mmy mind! You seem to grasp so much approximately
    this, such as you wrote the book in iit or
    something. I believe that you simply can do with some % to force
    the message house a bit, but other than that,
    tha is magnificent blog. An excellent read. I will
    certainly be back.

  11. Great beat ! I wish to apprentice even as you amend your website, how can i subscribe for a
    weblog web site? The account helped mme a acceptable deal. I were a ittle bit familiar of this your broadcast
    offered vibrant transparent idea

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: