Blocking spam traffic in google analytics

Beginner’s Guide to Blocking Unwanted Traffic from Google Analytics

My blog is still a little tiny baby blog with little tiny baby traffic, so every visitor counts.

If your blog or small business website readership is still pretty small (<10,000 sessions/month), unwanted traffic can really skew your analytics reports.

This post will show you how to:

  • Create a test view so that you can play around in analytics without risking your data
  • Identify unwanted traffic
  • Easily filter out most bot traffic from your reports
  • Filter out your own IP address from your reports

Want to follow along all of my easy analytics blog posts? Revisit Post 1 and learn how to set up Google Analytics through Google Tag manager, and subscribe here to have all of these posts straight to your inbox (this will not subscribe you to every blog post I come out with, only ones that are a part of this series).

Setting up a “test view” in analytics to protect your data

It’s a good idea to set up a “test view” in your Google Analytics. This makes it so that your analytic data is reported twice – once in an unfiltered view and once in a test view. You can make changes to this test view, and if you mess something up or later decide you want to filter in a different way, you can still see your raw and unaltered analytics.

Here’s how to set up a test view:

  1. Log into Google Analytics
  2. Select the “Admin” tab and make sure you are looking at the correct account and property. Under the View section, click “All Website Data”. Click “Create new view”creating a new view in analytics
  3. Name your view, select your time zone, and hit “Create”Creating a new view 2
  4. Success!

How to Identify Spammy Bot Traffic In Google Analytics

The first step in getting rid of spammy bot traffic is understanding that you have a problem in the first place.

Most bot traffic will show up as “Referral” traffic. Referral traffic also shows you traffic that comes from other websites that link to you.

GA spam referral traffic report

Log into your Google Analytics account and find your Referral Acquisition Report. You’ll find this in the left-hand menu after you click to expand “All Traffic”.

Click “Secondary dimension” and type in “hostname”.

For most of the results, the hostname will be your own root domain. This is most likely good traffic sent to your website from legitimate sources.

Wikipedia defines hostname as:

hostname definition

However you’ll notice in my report as well as yours that some of the referral traffic comes from hostnames other than your own domain – like (not set) or

In all of the accounts that I’ve worked on (including enterprise websites with 1,000,000+ sessions per month), I don’t think I’ve ever seen referral traffic from a hostname other than the website’s that was not pretty obviously spam.

Still not sure if it’s spam?

Take a look at things like % New Sessions and Bounce Rate. If the numbers look fishy – like 100% or 0% with a substantial amount of traffic, it’s probably spam.

Take a look at your own reports to gain more insight into your specific circumstances – considering that I’ve only had 542 referrals over the last month and bot traffic accounts for at least 271 of those visits, that’s kind of a big deal.

How to block spam hostnames from ruining your analytics

Note: Some people recommend eliminating spam by actually blocking bots from visiting your website with .htaccess. The solution I use does not make the bots stop crawling your page, but it makes it so that you do not see their traffic in your analytics. If you are having trouble with enormous volumes of spam traffic and performance issues, this solution will not help you.

That being said, here is a way to block spam traffic from appearing in your analytic reports:

  1. Remember the Test View you created with the directions above? Go to your admin section, find the right view, and click “Filters”
  2. Click “+ Add Filter”
  3. Create a new filter. Name it whatever you want – I named mine “Only My Hostname”, because it includes traffic only from my hostname. Select the filter type “Include only”, source or destination “Traffic to the hostname”, select expression “that contain”, and type in your root domain
  4. Allow some time for data to roll in, and then visit your referral traffic report
  5. Enjoy squeaky clean data with no icky bots!

You might also be ruining your own data

Do you visit your own website a lot to snag the URL from your latest post, look at changes that you have made, and admire your hard work?

Don’t lie, we all do.

When you visit your site, Google Analytics registers it the same as it does any other visitor.

If your website doesn’t have particularly high traffic or if you visit your site particularly often, your own traffic can also have a huge impact on your analytics.

You will most likely see your own traffic in your acquisition reports as “Direct” traffic – this means you typed in your URL or used a bookmark to reach your own website.

Direct traffic in google analytics

Unless you specifically want to measure how many times you visited your own website, you probably want to exclude your own traffic from your reports.

Here’s how to filter your own traffic out of your Google Analytics reports using your IP address:

  1. Go to your admin section, find the right view, and click “Filters”
  2. Click “+ Add Filter”
  3. Create a new filter. Name it whatever you want – I named mine “Block My IP”, because it filters traffic from my IP address. Select the filter type “Exclude”, source or destination “Traffic from the IP addresses”, select expression “that are equal to”, and type in your IP address
    1. Note: don’t know your IP address? It’s in your computer setting somewhere, I think. I don’t know, I’m not a tech person. An easy way to find it is by Googling “What is my IP address?” Google knows all.
  4. Bam! Done! Your data is now partying happily without you!

Each device that you own – laptop, desktop, tablet, smartphone, etc. – will have its own IP address, so you will want to block every device that you regularly use to visit your website.

Your own traffic may seem insignificant but when you are just starting your blog or small business website, it can have a huge impact.

Implementing these 2 filters will help you measure the behavior of only the users that you want to measure.


Excited to learn more about analytics? Click to subscribe to this blog post series or visit the Google Analytics Support website.


What questions do you have about Google Analytics?

Do you use any filters to clean up your data?