Global Header

Need help choosing a plan?Call our sales team at1-855-372-3679

5 Mins Read

Here’s How You Can Block WordPress Referrer Spam Traffic in Google Analytics

Home Blog Blogging Here’s How You Can Block WordPress Referrer Spam Traffic in Google Analytics
Spam has become a big part of the internet. While some types of spam use your server space to send out requests, others may take advantage of the users to send over harmful viruses and malware.   One of the common types of spam is called referrer spam. It majorly affects WordPress websites that are not prepared and may even get into your Google Analytics system, turning search engines against you and hampering your rankings.  You might not be able to prevent referrer spam completely but can definitely fight back against it by blocking it in WordPress and Google Analytics. Before we get into the nitty-gritty of understanding the process of blocking the referrer spam, let’s understand what is it. 

What is Referrer Spam? 

Referrer spam is a spamming technique where fake traffic data is sent to a WordPress website. It aims to taint a website’s analytics data with spammy keywords, domain names and URLs.  The spam affects your Google Analytics reports too as this data (fake traffic) appears under referral data and may affect the session reports, overall page views and bounce rates of your website. So, if you observe any suspicious-looking domains in your referral reports, probably they would be spam referrers.  

Methods to Block Referrer Spam Traffic 

Blocking these spam referrals can better your Google Analytics reports and ensure that the data isn’t contaminated by spam requests. You can do this with the simple methods listed below. 

1. Use strong software/security tool 

Referrer spam is just one of the many types of spam that can affect your website. Therefore, it is important to always stay prepared and ensure high website security.   To avoid such types of WordPress security threats and vulnerabilities, you can use a tool like Sucuri. It is a powerful firewall and security software for WordPress websites that protects your website against Trojan Malware and referrer spam.  Sucuri Website Firewall blocks the widely known spammy referrals by default. Moreover, whenever it detects new referral spammers, it adds them to the block list, preventing them from attacking your website.  

2. Blocking it manually with a plugin 

If you aren’t using Sucuri, then you can use this manual method to check the referral traffic and block them.  
  1. Install the Stop Referrer Spam plugin 
  1. Upon activation, navigate to Settings -> Referral Spam page to review the settings of the plugin. It uses a referral spam blacklist that Matomo publishes (formerly Piwik, an open-source analytics software) 
  1. You can even enter suspicious domains that are spamming your Google Analytics reports already.  
  1. Click on the ‘Save’ button to store your settings 
Note: Be careful while adding the domains in the plugin settings as it blocks all the traffic from that domain name. 

3. Set up Google Analytics filtering to block the ghost referrals 

Sometimes, even after applying the above-mentioned methods, you may see the referrer spam in your Google Analytics reports. Sucuri or any other plugins are unable to block them as these websites don’t visit your site at all. This type of spam is called ghost spam.  They directly send the requests to Google Analytics using your UA tracking code, the code used to connect your WordPress website with your Google Analytics account. As it is often added to the website’s header section, anyone can find the code and generate referrer spam with it.  To block these websites, you need to set up the filters in Google Analytics.  
  • Log in to your Google Analytics account, click the drop-down option at the top of your Analytics home page and choose the right website property. 
  • A popup window will appear. Here, you can choose your website view. 
By default, you will see the ‘All Website Data’ view. It is your website’s original and unfiltered view. 
  • After you have selected the appropriate property and original view, navigate to Audience» Technology » Network. 
  • Select the hostname as the primary dimension and expand the result to ‘Monthly’. 
Now, you will see a list of hostnames with numerous spam hostnames. You need to note down the valid hostnames for the website to create a filter.  
  • Create a filter inclusive of only the valid hostnames for your website by clicking on ‘Admin’ at the end of the Analytics panel on the left-hand side.  
  • Now you need to create a new view for adding the filters. Do not add filters to your ‘All Website Data’ or original view because filters are the permanent rules that are set for altering your Analytics data. If you commit any mistake while setting the filter rules, it will alter your website’s data permanently and give you incorrect reports. Therefore, create a new view for adding the filters by clicking on ‘Create View’ button. 
  • On the next screen, you will see a field to name the view you created. Give it a name and click on ‘Create View’. 
Now, your new Google Analytics view is created. You can view it in the drop-down in ‘View Column’ and add filters to this view. 
  • Check if your new view is selected and go to ‘Filters’. 
  • You will see the filter screen with the ‘Add Filter’ button. Click the button to get started.  
  • Enter your filter information here. Herein, add your filter name (like Valid Hostname Filter).  
  • Select your filter type as Custom and click on ‘Include’. Ensure that the Filter Field below is Hostname. 
You will see the Filter Pattern box where you need to enter your valid hostnames using the Regex string.  (Format – Add a ^ sign before every hostname and $ sign after it. Also, use the | sign to separate the hostnames and add a backslash (\) before the dot sign). 
  • Click the ‘Save’ button 
  • Check your Google Analytics reports after 24 hours to see if the changes are implemented. 
We hope this article helped you learn about WordPress referrer spam and how to block the same in Google Analytics.  
View All

Write A Comment

Your email address will not be published. Required fields are marked *

Longest running WordPress.org recommended host.

Get Up to 61% off on hosting for WordPress Websites and Stores.