Call 03332 207 677

Jack Evershed

How To Stop Referrer Spam in Google Analytics

10th Sep 2015 Analytics 2 minutes to read


How To Stop Referrer Spam in Google Analytics

The fight against referrer spam has long been a losing battle. It seems like every time a ‘solution’ is found, the spammers are already a step ahead, like a never-ending game of Whack-A-Mole.

A lot of people make the mistake of trying to block spam by using server solutions like the .htaccess or plugins. These will not work as this type of referral never visits your site and is merely fake data.

The spammers generate UA codes at random and send the fake data directly to the Google Analytics server via the back-end ‘Measurement Protocol’.

It’s a pretty ingenious way to annoy people and get affiliate traffic en masse, but there is one inherent flaw – as the UA codes are random there is no way of knowing what your particular hostname is.

You can exploit this flaw by implementing a ‘Valid Hostname Filter’. It is the simplest and most effective solution out there.

I’ve been giving these instructions to clients for the last few months and it seems to work very well. Let’s hope it lasts.

Here’s how to do it:

To find out your valid hostnames:

  • Go to the Reporting tab on GA and select the biggest timeframe possible on the date range.
  • In the lateral bar, select Audience
  • Expand Technology and select Network
  • At the top of the report, make sure you select Hostname because Service Provider is selected by default.
  • Find and copy all the valid hostnames.
  • Your valid hostnames will include all the places where you put your tracking code (UA-XXXXXX-1), such as yourdomain.com, yourdomain.com, blog.yourdomain.com.

How To Stop Referrer Spam

You can see from the example above that you may also have services in which you add your tracking ID, like an ecommerce provider, or in this case, a translation service for an international audience.

You may find official-looking hostnames like amazon.com, or even google.com, but these are planted there by spammers to deter you from removing them so your account can continue to be spammed.

Once you have this list, you will need to build a REGEX – don’t be put off by the scary name, it’s really easy. Just use the ‘|’ character to separate your domains.

This is the REGEX for the above example:

hampshirewoodprojects.com|hampshirewoodprojects.co.uk|translate.googleusercontent.com

To create the filter:

  • Go to the Admin tab and create a new view in the property.
  • Select New Filter.
  • Select Create New Filter and enter Valid Hostname Filter as a name.
  • In Filter Type select Custom.
  • Make sure you choose Include and select Hostname from the dropdown.
  • Finally, paste the REGEX that you built with your valid hostnames in Filter Pattern.

Verify the filter and you’re done!

How To Stop Referrer Spam

Always remember to create this filter in a new ‘view’ so you have something to compare the data to. Unfortunately this won’t work retroactively unless you know how to use custom segments, but with the new view there will only be the new data anyway.

If you’ve got any thoughts, please feel free to write a comment, or if you need some help you can reach me directly via @Jack_Evershed on Twitter.

Share this post

Jack Evershed
About the author

Jack Evershed

Straight-talking Jack is a bit of a know it all so be prepared for an all-out banter battle if you challenge his common knowledge – though he would make an awesome pub quiz partner. The whiskey-drinking, laid-back geezer will have you cracking up with his dead pan delivery and telling you exactly as it is.

results-bg

The Complete Google Analytics Guide For Business

Your Free Whitepaper

86 pages of goodness

Analytics Whitepaper Cover

What do you think?

  • aspect-ratio UK Search Awards Sam Noble Winner
    Cat Birch

    Samantha Noble Wins UK Search Personality 2016 at UK Search Awards

    The UK Search Awards is an exciting night for all; brimming with excitement, anticipation and pride, these awards showcase the very best in Digital Marketing. Our pride was overflowing as we watched our very own Sam Noble be honoured with the top prize of the night: UK Search Personality 2016.

    (more…)

    Cat Birch
    @MissCatBirch
    2nd Dec 2016
    News
  • aspect-ratio UK Search Awards Sam Noble Winner
    Cat Birch

    Koozai Shortlisted for Three Awards at the UK Search Awards 2016

    The UK Search Awards are here and we’re pleased to announce that we’ve been shortlisted for three awards at this prestigious ceremony.

    What an incredible year 2016 has been for us so far. We’ve celebrated turning 10 as a company, and in the last few months alone we’ve been nominated for a range of campaigns, won a bunch of awards and now we’ve been shortlisted for even more success.

    (more…)

    Cat Birch
    @MissCatBirch
    30th Nov 2016
    News

Digital Ideas Monthly

Sign up now and get our free monthly email. It’s filled with our favourite pieces of the news from the industry, SEO, PPC, Social Media and more. And, don’t forget - it’s free, so why haven’t you signed up already?