How to Remove Unwanted Referrers From Your Logs & Analytics

Remove Unwanted Referrers

When you spend enough time in your analytics, certain referrers of traffic to your site will definitely stand out if they keep appearing. Whilst referrers are typically a good thing as it means somebody is sending traffic to your site, this isn't always the case. In this post we will cover how we blocked a source of referrer spam from this site, however this same method can be used for blocking any unwanted referrers.

How to Block SPAM Domains From Accessing Your Site

The first step I undertook was to block the domains via my .htaccess file. You should find that all WordPress sites have one of these in your websites root directory. The code that I used is pasted below and was inspired by Paul Thompson from Buzzwords to Business. You can add the code to the bottom of your existing .htaccess file making sure to include any domains causing referrer spam. This should prevent further abuse from the problematic domains but unfortunately it is an uphill struggle and new domains are popping up all the time, so you may need to update this file over time.

The second step I took was to filter the referral domains from Google Analytics so that the spam attacks did not affect the accuracy of my analytics. The above methods should work for any unwanted referrers that you need to be blocked from accessing your site and skewing your statistics in the process.

“Data that is loved tends to survive.” — Kurt Bollacker, computer scientist, open-source advocate

2019 Update: Block Even More Referral SPAM

Time needed: 7 minutes.

A large percentage of referral spam bots will never even visit your website. This allows you to delete them by filtering out sessions that don't come from your domain name. Here is how…

  1. Log in to your Google Analytics dashboard

  2. Go to Admin > View > Filters

    Google Analytics Filters

  3. Click the + ADD FILTER Button

    Add Referral SPAM Filter

  4. Create a filter to only include your hostname

    Select a Custom Filter Type to Include traffic with Filter Field set to Hostname and the following Filter Pattern replaced with your own domain name and extension: ^yourdomain\.com$

    Referral SPAM Hostname Filter

  5. Click to Save to create the filter

WARNING: The method described above will filter the raw traffic data being saved to your Google Analytics account so you may want to add the filter in a new view.

It is also important to note that it will not impact any existing referral SPAM shown in your analytics already.

Leave a Comment

Your email address will not be published. Required fields are marked *