How to block referrer spam with Google Analytics filter

The most effective way to block ghost referrer spam from accessing your website and affecting your analytics data is to set up a custom filter directly in your Google Anaytics account. To find out if your website is affected read our blog post Is referrer spam affecting your website metrics?

Set up a View in Google Analytics

Before you can begin to use any of the techniques below we recommend setting up an additional view in Google Analytics. The benefit of views is that you can see the effect any filters you have applied are having by comparing data across filtered and unfiltered views.

By default, Google Analytics automatically creates one unfiltered view for every property in your account. This ‘raw’ unprocessed view is one in which the data has not been modified by filters. If you only have one view in your property, you will first need to create an additional view. Select the Admin tab and navigate to the account and property to which you wish to add the view. In the ‘View’ column, click the dropdown menu, select ‘Create new view’ then follow the on screen instructions. When you create a new filter using the procedures below, make sure you select your newly created view.

Filtering Ghost Referrers

Ghost referrers are visits that show up in your analytics account for visits that never actually took place. Instead of visiting your website the ghost referral is sent directly to Google’s Analytics servers. You can identify these requests by looking for any visits that do not include your hostname as their destination.

Reporting > Audience > Technology > Network > Primary Dimension: Hostname

analytics hostname-block referrer spam with google analytics

Make a note of any valid hostnames where you have installed your Google Analytics tracking code. In most cases this would be your domain and any subdomains, for example for our website this would be

In Google Analytics go to Admin > Select View > +New Filter > Create New Filter > Enter ‘Allowed Hostnames’ as filter name > Select Custom Filter type > Choose Include > Choose Hostname from list > Enter a domain name in filter pattern, ‘’. Click Verify this filter > Click Save.

block referrer spam with google analytics

Please note that filters can take up to 24 hours before they are applied to your data. Check back in a few days and don’t forget to set the data range in your reports to include only new data since the change.

We recommend you also block referrer spam from accessing your website directly by using an .htaccess file or WordPress plugin – see the links below. Please note that other methods may be applicable depending on your hosting platform and content management system.

Related blog posts

Is referrer spam affecting your website metrics?
How to block referrer spam with a WordPress plugin
How to block referrer spam with an .htaccess file

Share this article

Related Blogs

17Jan 18 

10 reasons people are leaving your website straight away

People leaving your website straight away is bad news. There’s never a time where you’d want someone to leave your website, but now it’s more important than ever thanks (or no thanks) to Google’s RankBrain. RankBrain is a complicated animal, but in a nutshell, Google are now paying closer attention if people click to your website from search results then immediately click back again. If someone does this, it’s a sign that your website didn’t satisfy them, and it’s likely Google wi...

20Dec 17 

Get to grips with your web traffic with Google Data Studio

Struggling to find the stats you’re looking for in Google Analytics? Then you’re going to love Google Data Studio! A relatively new product from Google, Data Studio allows you to create at-a-glance reports from multiple data sources, including Analytics, Adwords and Google Sheets. And even better, since February this year, Google Data Studio has been free to use for all businesses. Why use Google Data Studio? Instead of having to go into Analytics and spend time unearthing the key statis...

15Jan 16 

How to set up Google Analytics

Measuring your progress is an essential part of any successful digital marketing strategy. Google Analytics is a great free tool for measuring and analysing your web traffic, plus it’s fairly straightforward to get set up. If you’ve never used it before, here’s how to get started... Sign up to Google Analytics If you don’t already use any Google services, you will need to create a Google account at Ignore all the stuff about premium and sign up for a free account...

Join Our Mailing List