Block Google Analytics Spam

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 isn’t a pleasure to have to deal with. Really, it’s quite the opposite. And given that you’re on this page, you have probably experienced as much for yourself with the example of is one of the latest variants of this online nuisance and in this article we will aim to explain exactly what it does and why. Furthermore, we will also provide our readers with a simple, step-by-step removal guide, which will help you block the spammers and remove their presence from your GA statistics. However, before heading down to the guide, we do recommend you read through the following few paragraphs so as to gain a better understanding of what it is exactly you’re dealing with.

What does referral spam do?

There are two types of referral spam: classic referral spam – where it all began and which you aren’t likely to come across nowadays; and ghost spam, to which belongs. Both have essentially the same goal of driving traffic to the spamming website as part of a black hat SEO practice, which is generally not considered harmful or illegal. But it is frowned upon and Google is constantly trying to figure out ways to control it. And, as a matter of fact, with the case of classic referral spam – they very much succeeded.

Classic referral spam used bots and crawlers that were sent out to hundreds or thousands of different websites around the globe. Those bots would show up in their statistics as visits from the spamming website – just like with And there would usually be several of them with a near 100% bounce rate and practically no session time. The idea behind this was to get the website owners interested and curious enough to click back and visit the spamming website themselves and maybe figure out what’s going on. And with that, they were expected to generate traffic for that site, thus, boosting its ranking. The only thing is that at some point Google managed to put a stop to this, which gave birth to the phenomenon we now know as ghost spam.

Ghost spam chases the same objective, only uses a slightly different tactic, which allows it to be more elusive. Instead of employing the use of bots and crawlers, this form of referral spam simply enters data that will display visits from the spamming site in the Google Analytics stats of the victims. Thus, it achieves exactly the same purpose as its predecessor, only it doesn’t really generate traffic for that website and, therefore, doesn’t affect your ranking, traffic count or anything else of importance. The only thing that is altered are your stats. And though that does sound like a relief in comparison to classic referral spam, it really isn’t. Because the longer you allow to keep spamming you in this manner, you will end up with a really inaccurate set of statistics regarding your website’s audience. You see, the longer it operates, the more false data it puts into your stats. And the more false data there is – the less accurate those stats will be. You don’t want to at some point lose touch with the real picture do you?

Now, when you’re about to approach with the intention of blocking it, it’s equally important that you don’t choose the wrong path of doing this as it is that you don’t allow it to keep on doing what it’s doing. Many users commonly fall for the idea that the solution to their problem lies in the so-called Referral Exclusion list. It’s a functional tool, only if not for one little detail: it doesn’t block ghost spam. That’s not what it’s meant to do. And if you decide to put in that list in the hopes that the harassment will end, you will only get yourself into even deeper trouble. GA will not be able to mark the referral spammers as such and will only see them as legitimate traffic, because there were no genuine visits for it to track back. As a result, your traffic count will now be affected by the spammers’ activity and that’s certainly not something you’d want. Your best shot at blocking is using the instructions we’ve provided below and then perhaps considering in a better hosting service.

Block Referral Spam

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