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.

  • Peter Kirwan

    Hi Annie, thanks for another useful post. I’ve no problem doing this but tried recently, as part of a Roll up project, to add a filter after this one to rename the hostname but it doesn’t seem to take. Any ideas? I want to rename it because the ‘hostname’ is the domain’s IP address and this obviously looks bad in reports. Was trying to rename it to something more intuitive. Many thanks for your time!

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

      Hi Peter,

      Did you set it up this way (screenshot: http://screencast.com/t/2EuhhxhK2R)? Obviously, you would need to replace the example IP with the one showing up in your reports. You also have to make sure it comes after the filter that adds the hostname to your URLs.

      • Peter Kirwan

        Hi Annie,

        Thanks for the reply and going to the trouble of a screenshot! I certainly had it after the hostname filter and I think I set it up exactly as you suggested. In any case turns out the developer changed the site so that it shows a proper url rather than the IP now so problem has gone and solved itself. Still curious what went wrong though … Anyway thanks again

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

          Yeah, then there was some other funky monkey reason it wasn’t showing up, like maybe it wasn’t a dedication IP … or something.

  • Abhishek Yoga

    hi Annie, Great Post! I have implemented the same filter to show my full Domain Name. But whenever I want to visit that link, its a problem. the url being fetched will be repeated twice. by that I mean, upon clicking the small symbol to open the url in a new tab/page, the url is: http://www.mydomain.comblog.mydomain.com. Please suggest Y this might be happening? I appreciate your time and effort. Thanks!

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

      Yes, this is a bug in Google Analytics. Google Analytics adds the hostname to create clickable URLs. It wouldn’t be too hard for them to include logic that checks for the presence of the hostname in a filter and alter its code, but that hasn’t happened to date.

      • Abhishek Yoga

        Thanks for the reply. Keep up the great posts… really helpful.

  • https://twitter.com/ErinSimmonsSays Erin Simmons

    Hi Annie,

    Great post! I have a hostname addition I’d like to make with a slight twist and am looking for some advice….

    A section of our site is turning into a subdomain. Since that section of the site has historically brought in traffic within our main Analytics profile, I want to continue to track it there. The issue is I don’t want to wreak havoc on past data, as there are many people who use this account and external pivot roll-ups/lookups in Excel aren’t in everyone’s skill set. My proposed solution is to only add the hostname for the new subdomain so the main site’s data continues to come in with URIs and the new subdomain will come in with the whole URL. Based on that, I have two questions for you:

    1. Can you think of any potential issues this may cause?
    2. Any idea how I can get that advanced filter to work? Using your example screenshot, I’m thinking if I have the (Field A -> Extract A Hostname = subdomain.mysite.com), it should only pick up and replace pages coming in from that specific hostname with the full URL and leave the http://www.mysite.com pages coming in with just the URI. I’m not very familiar with the advanced filtering and need some guidance :)

    Thanks!
    Erin Simmons

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

      Fascinating test, Erin! I don’t anticipate any problems. You shouldn’t even need regex. If you just go to the Hostname report (Audience > Technology > Network > change primary dimension to Hostname), you can match it exactly. I’d love to hear how it turns out!

Powered by WishList Member - Membership Software