In the last year or so you may have noticed an increase in referral spam in you Google analytics account. It’s not only a pain when viewing your analytics, but it also can have other implications such as skewing your bounce rate and time on page. While there is still some conjecture as to the effect bounce rate and time on page has on rankings, we certainly see evidence all the time that bounce rate does effect rankings.

In most cases referral spam it created by software to hit your site en-masse. This normally shows up in your analytics traffic reports as fake traffic, or from particular website. A common referral website we’re seeing at the moment is “http://sharebutton.to”. If this particular spammer is hitting your site, it may show up like the image below:

sharebutton-co

What is the spammers intention?

Apart from just being a pain in the butt for your analytics, the main reason the spam, is that as a webmaster you will tend to visit the site out of curiosity, and place a cookie on your machine. They do this to millions of sites around the web, so their model is by the numbers. Generally the cookie will be linked to an affiliate program or similar, allowing them to take a cut of purchases or ads revenue.

How to stop it: 

While there is now real way to stop the spammer hitting your site, there are a number of ways to stop it showing in your analytics. While this works, I like to head it off at the server using the htaccess file. Before I explain how to do that, if you are not comfortable working with server files, it may be better to use the analytics option. A good tutorial on this method can be found here.

A word of caution: Messing with your htaccess file can cause your site to crash. It’s not as daunting as you think, but always back up your site before editing any files, let alone you htaccess file.

The Method:

1. Login in to your cPanel account and navigate to your public_html folder. Normally your htaccess file will be present in the folder as per below:

find-htaccess

If you cannot find the htaccess file, navigate to settings and make sure the “show hidden files” checkbox is ticked, as per below:

show-hidden-files

If you still can’t find the file, you may need to create one as a .txt file. Consult your webmaster if you are not sure how to do this. Otherwise there is a good tutorial here.

2. Open the htaccess file in the editor, or alternatively you can access your server via FTP. To find more information on this, please visit here.

3. Add the following code to you htaccess file:

# Block Referrer Spam
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly.\.ru/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.org/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.info/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*iloveitaly\.ru/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*econom\.co/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*savetubevideo\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*kambasoft\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*buttons\-for\-website\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*darodar\.com/ [NC]
RewriteRule ^(.*)$ – [F,L]

You can add a line or replace the specific referrer domain in the code. It doesn’t hurt to keep the common spammers in the code above. Just create a new line directly above the  last line with:

RewriteCond %{HTTP_REFERER} ^http://.*yourspammer\.com/ [NC]

Replace http://.*yourspammer\.com/ with the spammer domain.

So the code for your htaccess file would be:

# Block Referrer Spam
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly.\.ru/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.org/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*ilovevitaly\.info/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*iloveitaly\.ru/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*econom\.co/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*savetubevideo\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*kambasoft\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*buttons\-for\-website\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*darodar\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*yourspammer\.com/ [NC]
RewriteRule ^(.*)$ – [F,L]

If there is other code in the htaccess code, be careful not to delete it. The best place to insert it is at the very top of the file. So it’s as simple as that to block referral spam from messing up your analytics. Feel free to post comments below if you have any questions.