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 And my About page looks like /about/ instead of

Normally, that’s not a problem. But imagine if you have a site with multiple subdomains, like,,,, 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.



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.

Learn More

If you want to learn more about filters in Google Analytics, check out my Analtyics Audit Template, a self-guided, 147-page audit template that is regularly updated and will teach you how to do detailed analytics audits like a pro.


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


  1. E_3 says

    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 My full explanation of what I want to do can be found in this Google Analytics forum post:

  2. Matt McGee says

    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!

    • says

      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 …? 😛

      • Matt McGee says

        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.)

        • says

          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: 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.

  3. Peter Kirwan says

    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!

      • Peter Kirwan says

        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

  4. Abhishek Yoga says

    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: Please suggest Y this might be happening? I appreciate your time and effort. Thanks!

    • says

      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.

  5. says

    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 =, it should only pick up and replace pages coming in from that specific hostname with the full URL and leave the pages coming in with just the URI. I’m not very familiar with the advanced filtering and need some guidance :)

    Erin Simmons

    • says

      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!

  6. Todd Weise says

    Ohh.. so here’s an interesting problem. I’ve added the filter as you’ve defined it to a new profile that is tracking across 3 subdomains (a main site, a blog, and a Hubspot landing page domain). I’m seeing the full domains in the reports. Hooray (blog was previously on a different property/ua code, and Hubspot landings weren’t even being captured)

    I’ve created segments filtered by hostname for each of the 3 subdomains so I can easily look at one report and see how each domain is contributing to our overall traffic.

    The problem… my segment for, even when it’s the only segment in place, I’m seeing www. based URLs in the Site Content: All Pages report. :( Any thoughts?

  7. Todd Weise says

    Oh… and one note. In my segments, I have it set up to exactly match that segment’s URL with extra conditions where hostname ‘does not contain’ the other two subdomains.

    Obviously I can do a report filter to get out the bad records, but I was hoping that the segments would let me avoid having to do that.

    Also interesting to note. The blog segment is reporting on the blog. and the www. subdomains, but not the info. landing page subdomain. The landing page segment is pulling the info. and the www. but not the blog. subdomained pages.

  8. Todd Weise says

    Thanks Annie. The Onion Skin presents itself another layer… and just when I thought I was getting a better handle on all the things I never got deeper into.

  9. David Mc Guinness says

    Hi Annie, intersting post!

    I have implemented this filter to show my full Domain Name. However, when i go to my ‘all pages’ report all seems to work well but for a few pages the hostname is being duplicated, for example:

    Any idea how this could happen?

    • Annie Cushing says

      Hi David, can you attach a screenshot of your settings here or email it to me at annie(at)annielytics(dot)com?

Leave a Reply

Your email address will not be published. Required fields are marked *