Block Refferal in Google Analytics

The referral spam in Google Analytics is a new breed of problem. This page is dedicated to eradicating it from your GA statistics.

Referral spam can be a real pain in the neck and if you have found this page due to a recent encounter with one of its latest representatives – – then you have certainly come to the right place. On this page we will aim to tell you all there is to know about what the spammers want from you, how referral spam works and what threats it does and doesn’t represent to you. But more importantly, we have included a removal guide with a set of detailed yet simple instructions that will help you block this referral spam and rid your statistics from its influence. But before you head on to the instructions, do take a minute to really through the information presented in this article.

What is referral spam and is it dangerous?

First of all, let’s just put it out there that is not a virus or malicious program that is aiming to somehow harm you or your site. The goal of referral spam, be it the older classic referral spam or the modern ghost spam, is to generate traffic and boost the ranking of the spamming website. In the case of classic referral spam, this was achieved by means of bots and crawlers that were sent to numerous websites, generating hits for them. The only thing about those hits was that they had a near 100% bounce rate and little to no session time. This would them prompt the owners of those websites to check out why this mysterious visitor (the spamming site) was exhibiting such weird behavior. In doing so, they would essentially be visiting the website itself and generating traffic for it.

You’re not likely to come across classic referral spam nowadays anymore, because Google was able to more or less eradicate it. And that is when a phenomenon called ghost spam, to which by the way also belongs to, emerged. And the one significant difference between the two is that ghost spam doesn’t use bots and crawlers to do its dirty work. Instead, it simply enters data in your GA stats that shows you the same thing: the spamming website has been visiting your site, multiple times with a 100% bounce rate, etc. It’s the same concept, only now your real traffic count is not affected, nor is your ranking or pretty much anything else of significance. Only your stats are. However, as relatively harmless as it sounds, that, too, should to an extent be alarming to you.

Anyone, who is interested in the audience of their website, would like to have an accurate picture painted of that audience and its interaction with your site. By allowing spam like to enter false data in your statistics, that picture becomes tainted and over time – completely distorted. So in essence, you will at some point lose all perspective of what’s really going on with your site. For that reason, it’s really not a good idea to allow the spammers to continue doing what they’re doing, because they’re going to mess things up further. But even that is better than resorting to other measures, which we see users do time and time again and then live to regret it. We are talking about the Referral Exclusion list, which wise guys on the internet seem to think is the ideal solution to referral spam, probably because it has the word ‘referral’ in it, we don’t know.

This is a severe mistake, which can end up costing you dearly. What it will result in is Google Analytics basically heading over to check out the spamming website and find out that there are actually no spammers. Because there were no visits! Hence, the definition of ghost spam. What’s more, not only will it not find anything wrong, it will think of those hits as perfectly legitimate and will mark them as actual traffic. So now you will also have your traffic count polluted, not to mention having to pay for it. Instead, we recommend using the removal guide below to block the spammers in just a few easy steps. And after that you can start thinking about investing in some better hosting, because obviously the one you have now isn’t doing too good of a job in protecting your site from spam.

Block Referral 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!


About the author


Violet George

Violet is an active writer with a passion for all things cyber security. She enjoys helping victims of computer virus infections remove them and successfully deal with the aftermath of the attacks. But most importantly, Violet makes it her priority to spend time educating people on privacy issues and maintaining the safety of their computers. It is her firm belief that by spreading this information, she can empower web users to effectively protect their personal data and their devices from hackers and cybercriminals.


Leave a Comment