Digital Innovation Digital Publishing
2 mins read

Google Analytics: How to filter out spam traffic to get accurate data

Getting your Trinity Audio player ready...

When it comes to analysing your site’s traffic it’s often an assumption that the number of sessions you see in your Google Analytics account accurately represents the number of real people visiting your site, but this isn’t always the case.

Sometimes traffic isn’t a real person, sometimes it’s a bot, or spider, and sometimes it’s a spammer.

All this spam traffic needs filtering out and so, for a long time, analysts, webmasters, site-owners, and marketers have poured over resources online to set up filters within Google Analytics. From filtering out bad language settings, only recording traffic with the correct hostname, to simply blocking referrals from specific spam domains.

It’s been a game of whack-a-mole – reacting to when the problems pop up. What really needs to be done is to make your site more secure, ask more of your users to verify that they aren’t fake. Sounds like a tall order for your users, but really it’s not.

The easiest way for us to do that ourselves is with a little help from Google Tag Manager.

The Solution in a nutshell:

  1. Get Google Tag Manager to set a first-party cookie with any value we want (or use an existing cookie if you like)
  2. Set up Google Analytics to accept values to a new Custom Dimension
  3. Have the Google Analytics tag in Google Tag Manager insert the value it finds in the cookie to our new Custom Dimension
  4. Then, set Google Analytics to only record hits from traffic that includes the correct value in that Custom Dimension.

The way it works is that the current slew of fake traffic doesn’t ever reach your site, so it never gets the cookie, and traffic without the cookie never gets recorded in your Google Analytics view. It’s a secret handshake of sorts.

And now, in detail…