Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a web structure with a domain and a subdomain, let's call it example.com and blog.example.com. I want to be able to track both the main domain and it's subdirectory within the same Analytics profile so I've entered the same tracking code across example.com and blog.example.com

Tracking Codes:

This is the tracking code for the domain:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
  _gaq.push(['_trackPageview']);

  (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);
  })();

</script>

And here is the code for the subdomain:

 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
 _gaq.push(['_setDomainName','example.com'],['_trackPageview']);

 (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);
 })();

Issue

Notice I've used _gaq.push(['_setDomainName','example.com'],['_trackPageview']); for subdomain tracking. I see the post pages from the blog in the Analytics reports, but I can't distinguish between the homepage of the site and the homepage of the blog, they both appear in the reports in the same way (a slash /)

Question

Can anyone give me some insight on how to differentiate the homepage of the domain from the homepage of the subdirectory in GA reports?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

To see the domain name along with the request path in the reports, create an advanced filter for your profile with the following settings:

  • Filter Type: Custom filter > Advanced
  • Field A: Hostname
  • Extract A: (.*)
  • Field B: Request URI
  • Extract B: (.*)
  • Output To: Request URI
  • Constructor: $A1$B1

enter image description here

You can also create a profile for each subdomain. For example for site1.com:

  1. New profile named site1.com
  2. In the new profile create a filter Include site1.com traffic only
  3. Filter type set as Custom filter and Include
  4. Filter field as Hostname
  5. Filter pattern as ^site1\.com$

Repeat for each domain. Data will only be collected once the profile is created.

(Google's explanation)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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