Referral spams are manipulating Google Analytics status and overload server resources. These are just automated bot accessing your site. Spammer bot repeated your site homepage or post URL requests using a fake referrer URL. These spammers never visit your site. This Ghost Spam needs to put their site on your server access log or your analytics and gain your attention.
We can easily block referral spam. So no need to filter referral spam in Google Analytics. To stop this kind of Ghost spam we can use a firewall. There are many solutions out there. If you already have WAF firewall you can configure that service.
In this post, I’m going to use the Cloudflare free Firewall to stop referral spambots. This firewall not installed on your server, therefore these Ghost spammers never access your server. So you can protect your server overloading and slow down your site.
How To Stop Referral Spam With Firewall.
If you are not a Cloudflare customer, you can create a free account. Free plan enough for this method. With one firewall rule, we can add multiple Ghost bot domain or IP address. So in a single rule can block all the spammers before accessing your server or site.
- Go to Cloudflare “Firewall>Firewall Rule”.
- To create a new rule click on the “Create a Firewall rule” button, like the following screenshot.
- Next page you have to add the referral spammer details. In here you can add the IP address or spammer domain name like the following screenshot.
Adding the domain name.
This step we added referring domain name to block all the refer request coming from it. When someone accesses your site using blacklisted refer domain, that request block by Cloudflare. So no bot have to access your server or site.
- Under the “Field” dropdown menu select “Referer” option.
- Under the “Operator” select “Contains
- Under the “Value” type the domain name that you need to block.
Adding the IP address.
If you have server access log you can find the IP address of the bot. If you use shared hosting or blogging platform it’s hard to get the IP address. After you added the blacklisted IP when the bot accesses your server or site with that IP, all the request stop by Cloudflare.
- Under the “Field” dropdown menu select “IP Address” option.
- Under the “Operator” select “Equal“. Which means exact domain name should match to trigger firewall rule to block the bot.
- Under the “Value” type the IP address, if the referring spammer has IP range you can add that range in “192.0.2.0/24” format. Eg: IPv6 format “2001:db8::”.
- To apply the changes click on the “Deploy” button. It will take a few seconds to apply. If you changed the already created rule, it will take around 60 seconds to propagate globally.
In this method, you don’t need to create several firewall rules to block referral spammers, with just a single rule you can add each spammer “domain name” or “IP address” by using the “OR” firewall condition.
- Now almost all completed. Next, we have to specify what to do if the above criteria matched.
- Under “Choose an action” select “Block”.
Now you just block referral spam. All the added IP’s or domain referring bots never access your site. Your site or server not overload anymore.