Using custom segments to filter spam out of Google Analytics

Posted by Jon Haslett on 13 April, 2015 in Google , spam

Google Analytics has a spam problem

If you obsess over Google Analytics data like I do, you might have noticed some strange referral sources appearing in your your Google Analytics data that looks something like this.

Spam Referral Screenshot
Warning: Please don’t visit any of the websites mentioned in this screenshot, they may include scams or links to download software that could damage your computer.

Spammers read the Google Analytics code included in every page on your site and use it to send requests to Google Analytics. These requests make it look like a visitor has clicked a link from their website to yours.

At first glance it’s easy to think “I’ll just ignore shady looking domain names that appear in my referral list”. The problem is that spam hits always count as a new session/visitor, they always bounce immediately, and they’ll never do things like make a purchase or fill out a contact form. They’re negatively skewing just about every metric you might use to measure the success of pages on your website. This makes getting useful data from your website, and measuring your return on investment, more difficult.

On a local small business website this flood of fake visits can severely screw up a range of statistics including:

  • Bounce Rate
  • Goal Conversation Rate
  • Mobile/Tablet/Desktop usage percentages
  • New Session Percentage

At Dash Media, we regularly report to dozens of clients on how people are using their website and how it’s generating value for their business. This made it important for us to find a solution to this spam problem that can be scaled and maintained across many different websites without the spammers knowing that we’re filtering out their attempts.

Solving the problem with segments

In Google Analytics, a segment is a way of slicing up your site’s traffic and only looking at data for that particular segment of the data. Some default segments include Mobile Traffic, New Users. and Returning Users. The default segment that shows all website traffic is called All Sessions.

We’ve created a custom segment called All Sessions (minus spam) which functions just like the default All Sessions segment but excludes sessions where the referral source is on a list of spam domains that we’ve defined.

The great thing about using a custom segment like this is that it can be shared across all sites we manage, meaning that when we update the list of spammers with new spam domains the effects are automatically applied.

Custom Segment Filtering Spam
Screenshot showing what it looks like when we’re editing our custom segment.

You can install and edit our example custom segment here.

Here is the current version of the spam filtering segment that we’re using. You can install it for yourself and then edit the segment to add any additional spam referral sources that you’re receiving. To view the segment across multiple websites you can update the availability of the segment.

This guide provides a good starting point for anyone looking for an easy way to filter out spam referral traffic from their Google Analytics reports. Dash Media works with Google Analytics on a daily basis, and if you have any questions about Google Analytics feel free to ask using the social media buttons below.