How to Block referrer spam traffic in WordPress and Google analytics

Are you running your website on WordPress or have your own customized CMS? And getting referral spam traffic in your Google Analytics. Then don’t worry, today we are going to show you how to Block referrer spam traffic in WordPress as well as in Google Analytics

What is referral spam

The Referrer spam traffic is a way to increase the ranking of website traffic for spam website. The spammers want to increase their website ranking and search engine visibility, so they use referral spam methods. In short, the spammer sends multiple requests with fake URL’s to your website and site respond to that links and generate the content. In this way, the sites those publishing their access logs, including referrer statistics, will link back to the spammer website they want to advertise. Therefore, your website linking a low-quality website and helps them to improve rankings.

It also generates a fake traffic report in the Google Analytics as well as choke your bandwidth. In this article, we will show you how to block WordPress referrer spam in Google Analytics and save bandwidth.

Also if Google Algorithm detects that your website is linking to the poor websites, your own search ranking would be decreased.  

Block Referrer spam traffic in WordPress Using Plugin

WordPress Plugins directory has several plugins that can be used to block referrer spam traffic in WordPress. These referrer spam WordPress plugins have their own database of spam domains to block referrer spam. They are using web services to actively monitoring the referral spam websites.

Here in this tutorial, we are going to use two plugins: SpamReferrerBlock plugin and Block Referer Spam plugin.

Block referrer spam traffic by using SpamReferrerBlock plugin

Step 1: Go to your admin dashboard and plugins->Installed Plugins search for  SpamReferrerBlock.

Step 2: After installing and activating the SpamReferrerBlock plugin, go to settings ->Spam Referrer block settings page to configure it.

Step 3: At its admin page you will see several options to configure the plugin. It allows you to set what an evil spammer will see or even you can redirect them to custom URL.

block refrere spam traffic wordpress

Step 4: At the configure page, the plugin also gives the option to create a custom domain blocking list option. If you think that the plugin is unable to block some spam domains then add them manually. You can find them from your website Google Analytics data.

block refrere spam

Step 5: At the same plugin’s settings page, it will give you a detailed list of spam website domains lists that are actively monitoring and blocking.  The most up to date list of spam domain can be download from the server buttons. And if you want to help or share the list of your custom blacklist domains with the internet community,  then click on Upload server button

referer-block spam


Block referrer spam traffic by using Block Referer Spam plugin

This is another plugin which has same features as the SpamReferrerBlock plugin. Just install it from the WordPress plugin directory and activate to use it. On the configure page of this plugin, you will see the very straightforward interface and options. The Auto update is for updating the spam domain list automatically. The second option Block Mode, this option allows blocking the referrer spam traffic by using .htaccess or WordPress. If you do not have the .htaccess then WordPress block is preferable. Some other options are Manual update and custom blocks same as the  SpamReferrerBlock plugin.




Block Ghost Referrals spam Using Google Analytics Filtering

Before going towards the tutorial part lets know a little bit about the ghost spam.

What is ghost spam

Unfortunately, the WordPress plugins are not able to stop some referrals traffic. Some Spammers are so strong in hijacking Google Analytics ID to launch the false traffic directly to Google’s servers. Theses WordPress plugins are helpless because these websites are not visiting your website. They are sending the URL request directly using Google Analytics using your UA Tracking code. The UA Tracking code is easily visible and anyone can see by using view page source option.

How to block Google analytics ghost spam

Step 1: First login into your Google Analytics account

Step 2: Click on reporting tab and select Hostname. You will see all the spam domain list from where you are getting the referral spam traffic. Please refer the screenshots

Block referrer spam traffic google-analytica-repoting




Step 3: After performing the above step you can find out all the spam hostname in the list. Note down the valid  hostname list for your website.  For example,,,, are all valid hostnames for our website.


Step 4: Now click on the Admin tab and then Filter as shown in the screenshot.



Step 5: A filter screen will open, where you can set a filter reporting. Click on Add new Filter  button and configure it as follow:

  1.  Click on create new Filter option
  2. Give a Valid name to your filter as we have given Valid Hostname here.
  3. At Filter Type tab, click on custom
  4. Select Include option
  5. Under Include option, there is another field called filter field select Hostname option
  6. In the Filter, Pattern box enters your valid hostnames using Regex string. This filter pattern is very simple, just need to add a ^ sign before each hostname and a $ sign after it. Use the | sign to separate hostnames.
  7. The expression is given below just copy it, modify the hostname with your and paste it Filter pattern box.^$|^$|^$

You don’t need to put all of your subdomains if you have. Entering the main domain in the Filter pattern box will match all of them.






Step 6: Before saving the filter click on verify this filter link to see how the filter will affect your current view data, based on traffic. Please refer the screenshot.

Block referrer spam traffic verfiy-filter

Now finally click on save button and the effect of the filter will show in your analytics in at least 24 hours.

Filter to remove common Spammers in Google Analytics using Filter

If you have few common spammers in your list then you can use Filter exclusion option.

  1. Just create a new filter and instead of selecting the include option, select exclude as filter type.
  2. Under the exclude filter type select filter field called Hostname option
  3. In the filter, pattern box enters the common spammer sites in the given expression and save it. Change domain wth your’s spam domains.


You might like to see:


Also to get latest tech news and reviews on social media follow H2S Media on TwitterFacebook, and Instagram.