How To Add A Hostname Filter in GA

add hostname filter to Google Analytics

If your site has subdomains, there’s a filter that’s absolutely critical in Google Analytics (GA). It’s called a hostname filter.

The Problem

GA content reports only include the URI (which is just a URL minus the domain). So my homepage looks like / instead of www.annielytics.com/. And my About page looks like /about/ instead of www.annielytics.com/about/.

Normally, that’s not a problem. But imagine if you have a site with multiple subdomains, like www.yourdomain.com/, blog.yourdomain.com/, store.youdomain.com/, reviews.yourdomain.com/, etc.

The Ensuing Chaos

There are two primary points of chaos caused by unfiltered reports:

  • Think about it. What would the homepage of each of those subdomains look like? You guessed it: /. So analyzing the homepage of those homepages individually is impossible because they’re all going to blend together.
  • You can’t create advanced segments based on subdomains to compare their performance.

Yeah, basically you’re hosed.

How To Fix It

Okay, so let’s get on with fixing it, shall we?

    1. Click Admin in the upper-right corner of GA.
    2. Click the profile you want to add the filter to.

Follow the instructions in the screenshot below.

hostname filter setup

Click for larger image.

 

Caveat

When you add this filter it’s going to wreak havoc with your reports. So I always recommend making this switch on the first day of the month, so it doesn’t jack up your monthly reports. If you need to merge rows, you’ll need to use a macro or pivot table.

Update

I just updated the screenshot. Adrian Vender pointed out a typo. Thanks, Adrian!

  • redtiger1982

    Great tip, thank you! Are there any immediate ways to know it’s working?

    • http://www.annielytics.com/ Annie Cushing

      Thanks! Depending on traffic to your site, you should be able to start seeing full URLs in any content report within a few hours. I would take these steps to check:
      1. Change the date to today only.
      2. Go to Content > Site Content > All Pages.
      3. Enter your subdomain in the line item filter (http://www.screencast.com/t/gYUvoDesD).

  • E_3

    Just did this last week and it’s helping out big time!

    Related question:Have you ever come across a profile filter that will strip out visits to the domain, but combine all the subdomains? I’m trying to avoid setting up multiple profiles for each subdomain. I want a view of all the subdomains combined together, but exclude any visits to just domain.com. My full explanation of what I want to do can be found in this Google Analytics forum post:http://productforums.google.com/d/topic/analytics/DHtCcJainso/discussion

    • http://www.annielytics.com/ Annie Cushing

      Hmm … Yes, I’m sure it’s possible. I’ll need some time to tinker w/ it.

      • E_3

        Thanks Annie. Much appreciated.

  • Matt McGee

    Annie – I have a site with www. and forum. as separate subdomains. But I’m using different GA codes on each, so I assume this doesn’t apply, correct?

    ps – focus!

    • http://www.annielytics.com/ Annie Cushing

      Ohh good point! I’m going to add an update w/ a clarification.

      As to your question, no, it wouldn’t. However, unless it’s a really large site, using different profiles for subdomains is usually suboptimal. This is b/c when someone passes from one subdomain to the other, the browser suffers the dropsies with the cookie. So if someone lands on the www subdomain from Twitter, for ex, and then navigates to the forum, your www subdomain becomes the referring site, not Twitter.

      You can remedy this with cross-domain tracking though. Do you have that set up?

      Now let’s see … What was I doing before I got distracted with this comment …? :P

      • Matt McGee

        I don’t know if we have cross-domain tracking setup. I’ll have to check. I can find that in the “grab the code” section, right? Or is that just where we’d grab new code if we don’t have it setup? (It’s just a hobby site, so not really a big deal, but this is good to learn about.)

        • http://www.annielytics.com/ Annie Cushing

          I know Yoast has a WordPress plugin that adds it automatically, but it doesn’t look like the site is running on WP. I also saw this: http://www.lunametrics.com/blog/2011/12/01/automatic-cross-domain-tracking-revisited/. Otherwise, you just need to add a script to any link or form that points from one subdomain to the other. If you only have a few links it’s nbd to add. If you have a lot you would need an automated script … or a cheap intern. :)

          But you need to update your GATC to the asynchronous one and get it in the . You’re missing a lot of data. If you need help generating it, I can do it for you in a few mins. Or you can go to Admin > and turn on “Multiple top-level domains of annielytics” and whatever else you need.