Select Page

How to Block Referrer Spam in Google Analytics

This resource if your quick guide to blocking referrer spam in Google Analytics. Over recent years, we have been seeing a huge rise in referrer spam which is messing with everyone’s data, and we want to put a stop to that. This needs to stop and here are a few options for blocking referrer spam. To find out more about the different types of referrer spam, read our blog post. Before we look at the solutions to blocking referrer spam in Google Analytics, a quick word of warning. Do not implement any of these solutions if you are unfamiliar with what you are doing as you could easily block valid traffic to your website. If in doubt, get in touch to discuss your individual requirements.

 

Stop Referral Spam in Google Analytics

 

.htaccess Solution

If you are receiving spam within Google Analytics which is caused by spam bots actually visiting your website and triggering the Google Analytics JavaScript, then this solution is for you.

 

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} otherdomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* – [F]

 

Simply add this into your .htaccess file and add as many ‘RewriteCond’ lines as required for the bots you would like to block. There are a few pieces of terminology to explain in the above.

RewriteEngine on: This is always at the start of your .htaccess file

# Options +FollowSymlinks: This line is commented out as it often isn’t needed. Depending on how your web server is configured, you may need to uncomment this if you start to receive an error message of ‘500 Internal Server Error’. This means your server isn’t configured with FollowSymLinks in the ” section of the ‘httpd.conf’.

RewriteCond %{HTTP_REFERER}: Each of these lines will run the ‘RewriteRule’ if one of the conditions is met. For example in this case, if the referrer is from one of the spam domains that you want to bloc.

[NC,OR]: These flags at the end of the RewriteCond line should be present on all RewriteCond lines, except the final one. The NC flag stands for Non-Case-sensitive. The OR, stands for… or. So if this condition is met, or, the next condition is met, or the next one, etc.

RewriteRule .* – [F]: This rule will trigger if one of the rewrite conditions has been met. This rule is basically saying that anything that comes in will be shown the Forbidden message so that the page will never be loaded and the Google Analytics JavaScript will never be triggered.

 

Google Analytics Filters Solution

A lot of spam bots today never actually visit your website. Instead they simply send spam directly into your Google Analytics account with a clever bit of scripting. This presents a different challenge since the above solution using .htaccess simply will not work. Read more about this on the blog post about the topic.

 

Automatic Bot Filtering

Google recently introduced automatic bot filtering within Google Analytics which you can switch on to help remove some of the well-known bots. This new option will automatically filter out bots and spiders on the IAB know bots and spiders list. Before we jump in to look at how to implement this new feature within Google Analytics, it is important that you have several Views, 2 at the absolute minimum. One which is a completely unfiltered view and the other where automatic bot filtering is applied. Ok, so now you have this, we can look at how to apply the automatic bot filtering within Google Analytics.

Login to your Google Analytics account and go to the Admin area;

 

Google Analytics Admin Area

 

Then navigate to the View Settings within the specific view you use which is not the raw data view;

 

Google Analytics View Settings

 

Once in this area, you can select the checkbox to ‘Exclude all hits from known bots and spiders’ which will filter out some of those nasty spam bots from messing with your data;

 

Exclude all hits from known bots and spiders

 

This is the starting point. To fully filter out the many bots that you will likely be receiving, you need to look at manual bot filtering that is specific to your website. Unfortunately, this is a manual process and there isn’t any official list of spam domains that has been collated.

 

Manual Bot Filtering

To manually filter bots from your Google Analytics views, visit the Admin area again then click on the Filters menu item;

 

Manual bot filtering with Filters

 

Click on add ‘New Filter’;

 

Add New Filter Button

 

Then use the following filter settings to exclude the specific referral URL from future reports. Note, this will not remove any historical spam bot traffic;

 

Manual spam bot filter

 

Note that you need to character escape the period . in the domain names as this is a regular expression. You could make an individual filter for each and every known spam bot from your Google Analytics traffic, but life is too short for this. As such, it is possible to group together domains within the filter pattern as follows;

 

Filter 1: (ilovevitaly\.co|priceg\.com|blackhatworth\.com|econom\.co|hulfingtonpost\.com|semalt\.com|shopping\.ilovevitaly\.com
|.*\.darodar\.com|ilovevitaly\.com|iedit\.ilovevitaly\.com|cenoval\.ru|buttons-for-website\.com|bestwebsitesawards\.com)

Filter 2: (o-o-6-o-o\.com|humanorightswatch\.org|(.*)\.social-buttons\.com|s\.click\.aliexpress\.com|social-buttons\.com|4webmasters\.org|free-share-buttons\.com|theguardlan\.com|googlsucks\.com|buy-cheap-online\.info|www\.Get-Free-Traffic-Now\.com)

Filter 3: (trafficmonetize\.org|(.*)\.free-share-buttons\.com|www\.event-tracking\.com|howtostopreferralspam\.eu|sanjosestartups\.com|(.*)\.free-social-buttons\.com|guardlink\.org|непереводимая\.рф|www\.Get-Free-Traffic-Now\.com|(.*)\.social-buttons\.com)

Filter 4: (floating-share-buttons\.com)

Note: Multiple filters needed due to Google Analytics only allowing a maximum of 255 characters to be contained within a single filter

The list of domains that we are aware of that are causing a few problems currently includes the following;

Filter 1

ilovevitaly.co
priceg.com
blackhatworth.com
econom.co
hulfingtonpost.com
semalt.com
shopping.ilovevitaly.com
.*.darodar.com
ilovevitaly.com
iedit.ilovevitaly.com
cenoval.ru
buttons-for-website.com
bestwebsitesawards.com

Filter 2
o-o-6-o-o.com
humanorightswatch.org
free-share-buttons.com
theguardlan.com
googlsucks.com
buy-cheap-online.info
www.Get-Free-Traffic-Now.com

Filter 3

trafficmonetize.org
*\.free-share-buttons.com
www.event-tracking.com
howtostopreferralspam.eu
sanjosestartups.com
*\.free-social-buttons.com
guardlink.org
непереводимая.рф
www.Get-Free-Traffic-Now.com
*\.social-buttons.com

Filter 4

floating-share-buttons\.com

We will be keeping the above list updated to help block the ever growing number of spam domains for our clients. If you spot any other spam bots, let us know and we will update this list.

If you want to view your historical reports then you need to apply the same logic and use Advanced Segments to get a true view of how your website is performing.