Block Referral Spam in Google Analytics With One Easy Filter

Google Analytics is a great tool for measuring site performance, but the stats you see could be misleading if you’ve got a bunch of referral spam all up in your business. If mistaken as legitimate site traffic, this spam could screw up your data-driven decision making.

In this post I’ll explain how this spam gets into your stats, why it sucks and of course, show you how you can clean up the junk. You ready? 

Block ghost spam in Google Analytics with one easy filter - DataBabe Digital

Is it referral or ghost spam?

Referral spam is what you get when your web site is hit with a bunch of requests via bots/crawlers using a fake referral URL, which is often a site the spammer wants to advertise while trying to get their sites indexed. You may have even clicked on their links out of curiosity which is exactly what these spammers want (Pro Tip: Do Not Click). 

Ghost spam is a bit different. Unlike referral bots which crawl your site, ghost spammers are able to send fake visits to Google Analytics via HTTP requests without actually ever hitting your site. You could set up a referral exclusion list in GA to block the ghost spammers, but it’s a real pain in the ass because you’d have to continuously be updating your filters as more ghosts hit your site.

Google Analytics has a feature which allows you to block these bots but some crawlers don’t actually identify themselves as robots and therefore pollute your reports by showing a 0 second visit duration and 100% bounce rate. COOL.

ghost spam could mess up your data-driven decisions

How does this spam affect you?

I’d like to think these spam bots are relatively harmless most of the time, but puh-lease do not click on any of these suspicious or unknown sites. At best they’re just trying to get their sites indexed. On the flip, there’s always a chance that someone has some malicious intent and one wrong click could lead you to a site with spyware, malware, or viruses. Just don’t click! 

Also, as a business owner, wouldn’t you want your analytics to refer to the actual amount of visitors instead of some inflated number? I’d definitely rather have few visitors than have fake or ghost referrals. 

How can you tell it’s spam?

Let me show you where you can see the hostnames of the traffic that’s hitting your site.
From your GA reporting sidebar: Audience —> Technology —> Network —> Hostname 

check your audience network for ghost spam

In my case on this particular day, ghost traffic accounted for 85% of my traffic! 

google analytics ghost traffic spam

How can we block Referral spam?

A quick search around the interwebz will reveal a multitude of ways to filter referral spam. The problem is that these bots are smart, and they’re constantly evolving. While I have yet to come across a 100% guaranteed way to block all spam traffic, I can show you the best and easiest to implement.

Create a Hostname filter

The simplest way to block this traffic is to create a hostname filter in your views. The Hostname is the domain name of the page a visitor is on when they hit your site. This filter ensures that you are only including traffic from people visiting YOUR site.

It’s actually super simple. 

Admin —> View (TEST) —> Filters —> Add Filter —> Create New Filter
Predefined —> Include only traffic to the hostname that contain whateverhostname\.com

Note: any filters you implement will only include data from the date they were created. Also, it’s super important that you have multiple views when setting up filters, click here to read my post on successful Google Analytics implementation for more info.

create-hostname.gif

If you've got multiple domains you can create a custom filter to include all of them. Remember to escape the dots with a backslash and separate domains with a pipe.

custom domain filters in google analytics

And there you have it! Try implementing this filter on a Test view for a few days before setting it on your Master view. You will likely see a decline in site visits but the visits you do receive will be legit.

I am eager to hear your own experiences with handling referral/ghost spam. If you’ve ever found this to be an issue or if you have any questions or comments, please sound off!  

Did you know you can block most referral spam in Google Analytics with one easy filter? Eleven + West Block referral spam in Google Analytics with one easy filter. Plus, download the Ultimate Google Analytics Setup Guide - Eleven + West