How To Block Referral Spam In Google Analytics

This page was created to help you block the Referral Spam In Google Analytics. If you have recently been browsing through your google analytics you may have noticed an unusually high number of visits, likely with 100% bounce rate, from a site named This means that your site is subjected to a referral spam.

A few words on the phenomenon

Referral spam is an illegal technique employed by hackers to boost the popularity of websites that pay them to do so. Most websites have access logs and user statistics set to public so that bots and other applications can see and use them. This also applies to bots employed by search engines to index websites. These fake visits are indexed and the search engine may believe the referral spam website to be more trustworthy and rank it better. Active countermeasures have been steadily implemented by Google and other search platforms to minimize the effect of referral spam.

As of 2014 a new variation of referral spam exists (and makes use of it). Basically it relies on the curiosity of the site owner. When he notices the unusually large number of visits coming from a particular URL the owner of the website may click on that website and see what this is all about. You will get redirected to whatever website the spammer is currently promoting. This creates an actual link, as well as a visit to the beneficent site, which is exactly what the hackers want. The worst part about these so called “ghost referrers” is that they never actually visit your site, but they are still included into your statistics.

It should be noted that not always referral spam sites are actually maintained and hosted by hackers. Very often unsuspecting people have their sites hijacked into a bot network and all of their bandwidth is siphoned into use by the hackers. is annoying, but not dangerous

By all indications referral spam is not malicious and will not adversely affect sites that are targeted by it, but it will definitely pollute the statistics of your website. The longer your site is subjected to the spam the bigger the corruption of your statistical data. It is advisable that you take action immediately.

Most people familiar with the Referral Exclusion List will try to use it against the spam, but that’s a bad idea. This is the wrong lever to use in order to fix the problem. If you set up in exception in the Referral Exlusion List you’ll continue to receive visits from, only the location will be blocked. This means that this information will still be present in your Analytics, but now it will be impossible to tell which visits are real and which are the result of

What you are going to do is set up .htaccess rules, as well as a custom filter. We’ll go through these two methods in the removal guide below. Sometimes you can get by without one or the other, but it is advised that you set up both and solve your referral problems for good. The best part is that if you get targeted by a spammer in the future you can just quickly add them to the block list and be done with it.

How to Block Referral Spam in Google Analytics

STEP 1: In your Analytics account go to Admin —> All Filters.

pic 1(1)

STEP 2: Next, click New Filter and add in the Filter Name value.

STEP 3. Select the Custom Filter Type. In the Filter Field —> Campaign Source. In the Filter Pattern text box, add and click the Save button at the bottom of the webpage.

Pic 2(1)

Blocking referrer spam through .htaccess

If you know how to access your .htaccess file, you just need to input the following code in there:

RewriteCond %{HTTP_REFERER} [NC,OR]
RewriteCond %{HTTP_REFERER}
RewriteRule .* - [F]

If you don’t know how to access it, do the following:

Login to your cPanel account —> File Manager —> click the check-box “Document Root for—> your website. A side note: click on “Show hidden Files” and then Go. Find the .htacess file, right click it and choose Code Edit. Input the code I gave you and Save Changes.

Did we help you? A thank you in the comments goes a long way to warm our hearts!