How to 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.

If you have fallen victim to referral spam – we have the exact thing for you. Below this article you will find a detailed removal guide, which will assist you in effectively blocking the spammers and rescuing your GA statistics from the false data this ghost spam is responsible for entering. But first, we highly recommend you read through the following few paragraphs, as they will help clarify the essence of the issue at hand, how it operates and what you should abstain from doing in to order to avoid making bigger problems. We will also offer some advice on how you can potentially prevent future attacks of this kind. what it is and how it works is a type of referral spam, more specifically referred to as ghost spam. This is to distinguish it from its older counterpart, known as classic referral spam. Let us explain how both of these operate. In the case of classic referral spam, the spammers would send bots/crawlers over to the targeted webpages and create hits with little to no session time. Several visits would be created from their page, prompting the curious user to check this visiting site out. This results in you, the affected user, generating traffic for the spammer’s site. And imagine this happening on an enormous scale – that is how these sites strive to boost their rating and popularity. So, Google was quickly able to chomp down on the bot and crawler activity, which led to its almost complete extinguishing, but also made spammers find a different solution. Thus, ghost spam appeared, in which no spam bots are employed and, instead, only your Google Analytics stats are affected. The spammers create the impression that you have been receiving views from their site, whereas no actual hits were made. So, as a result, your traffic count, rating, site popularity and such are not changed – only the statistics you, as the owner or administrator of the site, see.

The problem with the above is that over time, those fake visits will accumulate and will start distorting the perception you have of your site’s views, visitors, etc. Sooner or later, you will no longer be able to adequately respond to your audience, as you simply won’t have an accurate idea of what’s going on in terms of actual traffic. Nobody, interested in the prosperity and well-being of their website, would want that. But what would be worse is if you tried to do something about it, without fully understanding the way ghost spam works and what repercussions your actions might bring. We’ve already explained how works, but if not treated correctly, you actions against it might backfire. If you try researching the topic of referral spam online, you will be bound to come across numerous suggestions of employing Google’s Referral Exclusion list. Do not listen to these suggestions, as entering the spammers in this list will wreak havoc on your stats and your actual traffic data, as well. Here’s what will happen: you will enter into the exclusion tool and Google Analytics will follow up to see whether or not you have indeed been visited by spammers. And since, as already pointed out, no actual visits ever happened – GA will not see a problem and will mark them as traffic. That will be devastating to your stats and will also lead to you having to pay for this non-existent traffic that you will keep on receiving, as nothing will have actually been done to stop

What you should do is follow the instructions in the guide below and consider investing in some better spam-blocking mechanisms. Those are essentially provided by your hosting service, so, provided that you have already suffered the effects referral spam, you might want to change to a better hosting. This might cost you a little more, but in the end it will all pay off, as the better the hosting – the higher quality of the spam filters for your website. If you are involved in affiliate marketing, where other sites have backlinks to your website, efficient spam filters are an absolute must-have, as spammers can use a weak link in the network of affiliates to affect you. Keep this in mind, as if you choose not to act on this now, you may end up in this very same situation again later.

Block Referral Spam

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

How to block Google Analytics Spam

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.

How to block Google Analytics Spam

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