How to Set Up Google Analytics Host Name Filters and Segments

By: Steven Dilmore

Recently we noticed a significant amount of traffic and projected revenue in a client’s Google Analytics account. The problem? It wasn’t a product the client sold … or had ever sold. This client has a physical store front as well as a healthy ecommerce website. As usual, at the beginning of our engagement with the client, we reviewed their Google Analytics account to ensure they were receiving accurate data.  While their ecommerce site produced tens of thousands of dollars through their website every month, millions per year, we noticed a significant spike in potential revenue that far surpassed their capacity – with, oddly enough, syringe sales, something this client never sold and certainly wasn’t planning on selling. This was throwing off all their reports.
Google analytics example

Of course, the consequences behind tracking erroneous data from Google Analytics range from marginal to obstructive. And like us, you’ll want to find out what went wrong.

We first researched the source of the problem. We began by analyzing the tracking code that the client was using to pull data into Google Analytics. Word to the wise: that tracking code can’t be hidden from savvy web users. It exists in the header HTML of your site. So, a few things could have happened (and may happen to you). One, it could have been accidentally left on an old site that’s no longer monitored, which wasn’t the case for this client, since they never sold this type of product. Two, the issue could be caused by an external web user copying your tracking code and sending fake traffic to your site by adding it to their website. Why does this happen? A variety of reasons, two we’ve noticed:

  • Competitor who wants to make your site unreliable
  • Someone selling spam software to try to get you to invest in their software

Google offers two fixes to this, using either hostname segments or filters. Your hostname essentially tells Google to look at where that tracking code actually lives, so if it’s hosted on your domain name, and you’ve set up a filter or segment, Google Analytics will only honor the data that comes from your domain, not the data coming from these other sites.

google analytics audience overview

Here’s a quick breakdown of these two solutions:

  1. Setup Hostname Segment: With this method, you won’t lose any data. There’s less risk involved in this case, and you just rebuild the segment and pull in the data as needed. Drawbacks? You’re still collecting that spammy or obsolete data, and you still need to reapply that segment every time you want to use it.
  2. Setup Hostname Filter: This is a more permanent solution. It applies a filter to a view and it won’t record that data at all. Drawback on this one? You do need to be careful that you configure the filter properly or you risk losing valuable data indefinitely. We recommend setting up a test first in order to initiate.

Who Benefits from Hostname Filters and Segments?

We recommend that any marketing or SEO expert should know how to set this up in Google Analytics. It’s probably not going to be a problem for a client who doesn’t have a lot of site traffic, or for companies who don’t have ecommerce, but it’s not unusual to see errors like this on any website. It certainly doesn’t hurt to use on every website just as a precaution to ensure that the data you’re pulling into analytics isn’t full of spam, archaic data from previous sites, or errors that ruin the metrics you’re trying to read. Of course, this is just one reason why you may be experiencing erroneous data on your website, and troubleshooting is tough, but this setup is simple enough and will ensure the data is coming from the right host.

Steven Dilmore headshot

About Steven Dilmore

As a Business Analyst at Aptera, Steven is a Professional Scrum Master and uses his knowledge to translate business goals into actionable requirements with a focus on delivering value. He specializes in coordinating stakeholders across continents.