Analytics Pros

.
Home Blog Google Analytics Monday Q & A: showing your site's domain name in content reports

Monday Q & A: showing your site's domain name in content reports

This is the first of what I hope to make a regular series on Monday mornings: Q&A. Send in your questions throughout the week, and I'll pick one to answer on Monday and get your week off to a great start! This first question came in over the weekend and relates to a topics that has certainly been written about before, however I thought I'd write my own response to this question rather than simply referring out to a help article on Google or other blogs so I can introduce in a bit of my own experience on the matter and a slightly different, and I think improved, take on the filter for the job.

The Question:

I am new to this GA but have worked with WebTrends in the past. I've implemented the GA code on the site I'm responsible portion, which runs on a sub-domain of our main domain [sub.domain.co.uk]. The page hits are appearing fine in Content Reports without the domain name [i.e. "page.html"], but the domain name is not shown properly in the URL reported within Google Analytics. When clicking the "view page" link the reported page is our main domain [www.domain.co.uk].

How do I get the sub-domain name to show in the pages listed in the Content Reports?

The Answer:

What you're seeing is standard given how GA works. The "page" is the potion of a URL after the domain name. To get the domain into the content reports you need a filter that copies the hostname field into the Request URI field in Google Analytics.

First, I'd verify what hostnames are being recorded by GA: go to Visitors > Network Properties > Hostnames. Here's the hostnames report for my site:

hostnames-report-example

Caleb's tip about hostnames in Google Analytics

note how the hostnames report contains "www.analyticspros.com" and "analyticspros.com".  Why is that?  Well, it is because some visits came in while browsing http://analyticspros.com/ while most came in from users browsing using http://www.analyticspros.com/.  This subtle difference is actually not so subtle.  Technically, "www." is a sub-domain.  However, since this has been around as long as, oh, the World Wide Web, it is basically treated as the de-factor standard part of a domain name.  Google Analytics treats "www" and "no-www" domains as the same insofar as the cookies it sets, however the hostnames are still reported as-is, www included or not.

This presents a problem for filtering the hostname into your content reports: you'll introduce fragmentation into the reported content.  The homepage could be "/analyticspros.com/index.php" or it could be "/www.analyticspros.com/index.php" since some visits used the non-www and others the www versions of the domain.  The solution to this problem is included in my version of the hostname-to-URI filter.  Note: there are SEO implications to hostname issues as well, and there's an easy fix.  Check out this article from SEOmoz.org on the topic of domain redirection and canonicalization (see the part about "redirecting canonical hostname" towards the bottom).

The perfect Hostname to Request URI filter

To get the domain (or "hostname" as its referred to in Google Analytics) showing in the Top Content and other content reports, you can create a filter to copy the hostname field into the Request URI field like this:

hostnames to request uri filter

  • Filter Type: Custom Filter
  • Type: Advanced
  • Field A: Request URI
  • Field A pattern: (.*)
  • Field B: Hostname
  • Field B pattern: (^www\.)?(.*)
  • Output field: Request URI
  • Output Pattern: /$B2$A1
  • Field A required: yes
  • Field B required: yes
  • Override Output: yes

Notes about this Google Analytics content filter:

  • The leading slash before the "hostname" output pattern is essential. If you leave this off, Content reports will have no leading slash. The leading slash is important for certain reports within Google Analytics to operate correctly.
  • In Field B pattern the "(^www\.)?" part in  means "find the hostname that begins with 'www', if it exists, and put it in memory slot B1.  The second part "(.*)" means "find everything after the 'www', if it's even there, and put it into memory slot B2".  The result of this is is that hostnames with or without the "www" will be reported as the same thing: without www in your content reports.
  • Since this filter modifies the URL reported, it will render the Site Overlay report unusable, as well as the "view this page" options under Content reports. The reason for this is that both of these features rely on an implicit understanding of your website's location and the content you're veiwing. Site Overlay works by comparing links in the HTML of your page and URL's reported in your Content Reports. Unless there is an exact match, it won't work. Since you're modifying the URL reported by GA, that match can't happen when you're using this filter. For the "view this link" clicks GA relies on the domain name entered in your profile configuration section and the URL in your content report, thus when you copy the hostname field into the URL the view links won't work because there is inherently no match.

 

That's it!  Feel free to post back questions or feedback here.  Thanks for reading, and be sure to send in your question about Google Analytics, from which I'll choose one to answer on the next Q&A Monday.


Comments(6)
Display #
 Leading slash needed? (pls elaborate)

By: Phil on 2010-Jul-20 15:00:01
Hi Caleb,

A useful post. I look forward to more Analytics Pro Monday`s :)

Quick question…

* Please could you elaborate on why the leading slash is needed (or which GA reports break if it is missing)?

For example you suggest:
-

 Re: leading slash needed

By: calebwhitmore on 2010-Jul-21 11:43:44
Phil,

I've seen content navigation and entrance path reports not work correctly without a leading slash.  Also, the "view this link" and Site Overlay reports need valid Request URI stem portions, and a URI stem begins with a slash.

-Caleb

 Tracking Across Sites

By: periscopeup on 2010-Aug-25 07:16:20
Caleb, great post. One question. I'm implementing this on an enterprise GA installation that uses 9 different sites (www.site1.com, www.site2.com, etc), so I'm in the process of implementing cross domain tracking in the code snippet.

Can I use the technique you describe here to ALSO track this ACROSS multiple different domains? Right now, the implementation uses a different profile (different UA #'s) for each site. Would I have to combine them all into a single profile?

Thanks!

Dan from www.periscopeUP.com

 Re: Tracking Across Sites

By: calebwhitmore on 2010-Aug-25 10:48:20
Dan, 

 First, are you wanting to simply unify sessions across all sites, or be able to report data from all sites in one place, or both?  The answer dictates what you need to do.

Tracking across all sites in the latter fashion, i.e. treat all 9 sites as one site, requires this:

1) Defined setAllowHash(false); in all GA tags on all pages of all sites
2) Define setAllowAnchor(true); in all GA tags on all pages of all sites
3) add the _link() method to 100% of all links between all sites
4) Have all sites use the same Web Property ID reporting to the same profile in the same account.

You can have this along with a second tracker that reports data into a dedicated account for each site, but you have to ensure the trackers for the cross-domain and the site-specific trackers don't conflict with each other.

You could also use a 3rd party iFrame to unify tracking to a central domain, but you'd have to ensure you have appropriate P3P headers there and also be OK with not tracking anyone using Safari.

The tagging of all links with the _link() function is the biggest challenge if you want to unify sessions across all the domains.  Our Analytics Engine product can automate that so it's complete and doesn't require modifying a stitch of code.

Hope this helps,

-Caleb

 Re: Tracking PDF downloads

By: calebwhitmore on 2010-Aug-31 09:29:50
Hi Rao,

This is important to do and in fact we've built a product specifically for tracking PDF downloads, among other things.  It's called Analytics Engine and costs as little as $50 per year.  You can see more information here: www.analyticspros.com/products/analytics-engine.html.

Best,

-Caleb

 Tracking PDF downloads

By: rao on 2010-Aug-31 06:17:38
Can we have code to track download the PDFs automatically using Google Analytics.

Regards
Rao

Add Comment
 
Follow analyticspros on Twitter

Bookmark and Share

Subscribe in a reader

Enter your email address:

Delivered by FeedBurner

Community Login


Google Analytics Certified Partners & Authorized Consultants - click to verify
Google Analytics Certified Trainers
Urchin Software Certified Partners & Authorized Consultants

Performance Marketing with Google Analytics

Customer Reviews

Read customer reviews of Analytics Pros at the Google Solutions Marketplace.

The Name Says It All 'Analytics Pros'

SF Search Marketing

Hire Analytics Pros - You'll be glad you did!

Lisa Thayer

Analytics Pros Are My Go To Guys

Jonah Stein

Product Highlight

Measure the complete picture of website activity with APE, the Analytics Pros Engine. APE extends Google Analytics tracking to include page-level interactions including outbound links, file downloads, email address clicks, forms, buttons, scripts, and more.  Learn more about APE today!