Internet Marketing Tips, Suggestions, & Ramblings

How To Track Traffic Across Multiple Subdomains With Google Analytics

Google Analytics provides a default JavaScript code which will need to be implemented into the code of your web pages in order to start tracking the traffic to your website. However, you might have a site with sub domains and if you do not customize your script, your data won’t be as accurate as it could be. Depending on how you currently have Google Analytics (GA) setup, you might see your main site listed as a referring site.

Here are the 5 steps to follow in order to get the most accurate data from a website with multiple sub domains:


Create a profile for your main site in your GA account.

Step 1

Step 2:

To track traffic across sub domains, you will need to add an additional line of code to your script called _setDomainName(). For example, if contains sub domains, the code would look like the following:

Tracking Code

Step 3:

Create a duplicate profile for each sub domain and name the profile with the sub domain name. (Note: Your “UA-XXXXXX-X” will be the same). Look for “+Add New Profile” on the GA Overview page.

Step 2

Step 4:

Add a predefined filter to each duplicated profile. Look for “Edit” on the right side of the Overview page in the same line as the profile:

Step 4.1

Then look for “+Add Filter”:

Step 4.2

Now, add a filter to only include traffic to this particular subdomain:

Step 4.3

Step 5:

If your subdomains contain URLs with the same request URI, you will need to do one more step. The request URI is everything that comes after the domain name on a URL – for example: –  /page1 is the request URI. GA reports only show the request URI and if the main site and subdomains contain the same request URI, you will not be able to differenciate the traffic for these pages.

In order to fix this, you will need to add an advanced filter to have GA show the complete URL in the reports. Again, you will need to add a new filter:

Step 5

So this is how you can track your website traffic if you have a site with multiple sub domains – you only need one GA account and one GA profile with many duplicated profiles with predefined filters.