Tag Archive | "Search Engines"

Google Analytics Tip – Tracking Subdomains

Tags: , ,

Google Analytics Tip – Tracking Subdomains

Posted on 20 May 2010 by RChurt

Here is the step by step on how to track a subdomain in Google Analytics. This will work for anything like blog.domain.com etc which may be set up for strategic purposes.

How to add a subdomain as a new profile:

This is the easiest way to track a subdomain. Creating a separate profile for each subdomain allows you to track traffic in Google Analytics for each subdomain separately.
  1. When you are in the analytics overview/profiles section (where you see your URL, view report option and some overview stats) there will be an option (within the gray area) on the right to click “+ add a new profile” … choose that
  2. Add a Profile for a new domain and enter “subdomain.example.com” as the domain. (note you do not want to add www. for a subdomain at all)
  3. Just copy the new code that is then provided into your HTML footer.

How to track a subdomain within your existing Google Analytics profile:

This option is to track subdomains within the same profile as the domain. (this is more complex) In order to do so, you’ll need to add a line to the tracking code on each page of your site. The instructions below assume that this profile was set up with the primary domain as the listed website (e.g. .example.com)
  1. Add the following line (in bold) to the tracking code on all pages of your subdomain and your main domain:

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
try{
var pageTracker = _gat._getTracker(“UA-xxxxxx-x”);
pageTracker._setDomainName(“.example.com”);
pageTracker._trackPageview();
} catch(err) {}
</script>

Enhanced by Zemanta

Comments (1)

About the Author


Put on your thinking caps - I am, Rebecca Churt, an Inbound Marketing consultant, and am here to share my thoughts (and only my thoughts) on blogging, SEO and social media.

Contact me if you are a health business, nutritionist, life coach or personal trainer in need of marketing assistance or interested in having a custom blog for yourself. See examples of my design work.

You can also follow my most recent work at

Recent Posts