I have a WordPress multisite with two sites. One at the main domain, and one at a sub-domain. I have Google Analytics running on both sites, and it is turned on to track sub-domains. See screenshot:

enter image description here

I have this piece of javascript on each site in header.php:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'my-UA-code']);
_gaq.push(['_setDomainName', 'andy-warren.net']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


I'm getting data in Analytics, but I don't know how to differentiate between the domain and the sub-domain. Am I missing something in the settings or piece of tracking code? Or can I just somehow choose to see the domain or sub-domain in Analytics?

2 Answers 2


You can create a profile to look specifically at both the subdomain and domain.

1) Go to Admin > View (Profile) and "Create new view" (under the dropdown).

2) Create a filter that includes only traffic from the hostname that are equal to andy-warren.net. This will be your andy-warren.net top-level domain profile.

3) Create a filter that includes only traffic from the hostname that are equal to subdomain.andy-warren.net. This will be your subdomain.andy-warren.net subdomain profile.

Third, you could have a profile (probably the profile your currently using) that contains no filters i.e. it's a rollup/global profile for all your websites.


If you would prefer to see both of the sub-domains listed in one profile, add a filter to the profile with both domains with: Filter type:custom filter Advanced: Field A -> Extract A Hostname (.) Field B -> Extract B Request URI (.) Output To -> Constructor RequestURI $A1$B1 Field A Required Field B not required Override Output field yes Case sensitive no.

Then you will see the full url of the page including the domain and subdomain when looking at content. It makes it easier for comparisons between pages this way. It will only make the change from the date you add in the filter though, so test this in a blank profile before you put it in your live one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.