Ghostbusters II: Removing historical ghost referral spam in Google Analytics

No more ghost referral spam!

We previously covered an overview of referral spam (or ghost referrals) in Google Analytics (GA), which are referrals that can muck up your webtraffic metrics, monitoring, and analysis by generating fake visitor data for your website. Spammers accomplish this by using spam bots to get your Google Analytics tracking ID (e.g. UA-) from your website’s source code. Next, the nefarious spammers send “visitor” information directly to Analytics (bypassing your website).

If you’ve been coping with referral spam recently, you’re not alone. You might be asking yourself something like “why isn’t Google doing anything about this?!” Mike Sullivan at Analytics Edge points out that “they have said they are working on it, but it is a tough fight. Trust me — it would be a LOT worse than it is if they were doing nothing.” Fortunately, we’ve got the tools to help quash those spammers!

Getting rid of Google Analytics referral spam retroactively

In our last post on the topic of referral spam, we demonstrated some strategies for suppressing ghost referrals from incoming Analytics data. In this post, we’ll go over techniques to retroactively filter referral spam from your Analytics metrics. This feat can be accomplished by using advanced segments in Google Analytics.

If you’ve already set up conditional filters, this process will seem very familiar to you. First, navigate to your Analytics dashboard and click “Add Segment” at the top:

Creating a new segment in Google Analytics


From here, you’ll want to make a new segment:



Here’s where things get a bit trickier. The next four steps will help to get your conditional filters set up:

Setting filter parameters for your new Analytics segment

  1. Give your new segment a descriptive name (e.g. “spam filter segment”)
  2. Go to the Conditions tab under the Advanced options.
  3. Here, you can create a conditional filter to include or exclude data from your reported metrics.
  4. You can create the parameters that your filter uses. In our example, we’re choosing to exclude visitor data from sources whose Language field contain spammy names (e.g. “Vitaly rules google”).

You can click the “Add Filter” button to add more filters. Creating a variety of inclusionary and exclusionary filters across multiple domains (hint: the “Source” domain is a great place to start) will allow you to tailor the incoming data in your Analytics account. Be careful not to filter real data, though!


Between this post and our earlier tutorial on filtering Google Analytics spam, you should be well on your way to becoming a full-fledged Ghost(referral) Buster. Unfortunately, the spammer problem isn’t going anywhere, so it’s prudent to be as well-equipped as possible to deal with them.

The persistent endeavor of spammers to infiltrate your Analytics data has recently been exposed to be (at least primarily) the sole effort of a Russian hacker who was upset that Google closed his AdSense account. Until Google figures out a way to shut him (and others like him) down, stay alert and keep an eye on your metrics!