When tracking your website traffic, it’s important to look for fake visitors or referrer spam. At WPBeginner and our other brands, we’ve experienced bot traffic on various occasions. These are visitors who come to your website and exit immediately.
Referrer spam sends misleading data to your site, which can pollute your analytics reports with spam links. As a result, you don’t get a clear picture of how your website is performing. This can negatively impact your efforts to optimize the user experience and prevent you from growing your online business.
To deal with this issue, we’ve tried and implemented different methods. For instance, you can use a security plugin that filters spam traffic, use a plugin that blocks referrer spam or list ghost links directly in Google Analytics.
In this article, we will show you how to block WordPress referrer spam in Google Analytics effectively.
What Is Referrer Spam in WordPress, and How Does It Affect Google Analytics?
Referrer spam in WordPress is a common spamming technique where fake traffic data is sent to a WordPress website.
This spam technique aims to pollute a website’s analytics data with spam URLs, keywords, and domain names.
It affects your Google Analytics reports as this data appears under Referral data and may affect your website’s overall page views, bounce rates, and session reports.
If you are seeing lots of suspicious-looking domains in your Referral reports, then they are most likely spam referrers.
Blocking these spam referrals will improve the accuracy of your Google Analytics reports and ensure that spam requests do not pollute your data.
That said, let’s look at how you can view referral traffic in Google Analytics and identify spam.
How to Check Referrer Spam in Google Analytics
Before you take any steps to block referrer spam, you will want to check that your website is experiencing it.
You can identify referral spam in Google Analytics. To get started, log in to your Google Analytics account.
After that, you can go to Reports » Acquisition » Traffic Acquisition.
From here, you’ll see different traffic sources for your website, including referrals.
Next, you can click the ‘+’ button to add another dimension.
You will now see different secondary dimensions to filter your traffic.
Simply head to Traffic source » Session source from the dimensions dropdown.
Google Analytics will now show the ‘Session source’ dimension of your traffic.
You can go through the list and look for domains that look suspicious or strange. A simple way to spot them is by looking at the engagement time. If it is 0 seconds, then they can be referrer spam.
Note: If you’re new and haven’t setup Google analytics properly, then we recommend using our guide on how to install Google Analytics in WordPress.
Now, let’s take a look at how to easily block referrer spam in Google Analytics on a WordPress website. We will cover different methods, so you can click the links below to jump ahead to any section:
Method 1: Block Referrer Spam in Google Analytics with Sucuri
One easy way to block common referrer spam in Google Analytics is by using Sucuri.
It is one of the best WordPress security plugins and comes with a website firewall. The firewall blocks most common website threats, including referrer spam, before they even reach your website.
At WPBeginner, we also used Sucuri as our security plugin before switching to Cloudflare. It helped us block over 450,000 WordPress attacks in 3 months. To learn more, please see our Sucuri review.
Sucuri also comes with website monitoring, a malware scanner, an integrity check, and dozens of security features. This protects your website against hacking, malware, and brute force attacks.
Important Note: We have compared Sucuri and Cloudflare in-depth, and in our opinion, Cloudflare offers a more powerful collection of security features. It is also great for blocking referrer spam.
We’re recommending Sucuri here because it’s a solid tool and the far more affordable option. That said, if you are looking for a more comprehensive tool and you have the funds, consider checking out Cloudflare as a broader security solution instead.
First, you’ll need to install and activate the Sucuri plugin. If you need help, then please see our guide on how to install a WordPress plugin.
The best part is that you don’t need to perform any additional steps to configure the plugin, as it works out of the box. After activation, Sucuri will start protecting your site from referrer spam and also scan it for malware.
You can also head over to the Sucuri Security » Dashboard page to see if the plugin found any immediate issues with your WordPress code.
To learn more, please see our ultimate WordPress security guide.
Method 2: Blocking Referrer Spam in Google Analytics With a Plugin
If you don’t want to use Sucuri, then you can use the Analytics Spam Blocker plugin to check referral traffic and block them manually. It is a free WordPress plugin that prevents any kind of spam from reaching your website by blocking it at the server level, leaving your analytics data untouched.
First, you need to install and activate the Analytics Spam Blocker plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you need to visit the Tools » Analytics Spam Blocker page from the WordPress dashboard to review plugin settings.
The plugin uses a referral spam blacklist to stop suspected sites from reaching your site and ruining analytics data.
Under the ‘Add a Domain’ section, you can also enter any suspicious domains that are already spamming your Google Analytics reports. But be careful when adding domains in the plugin settings, as it will block all traffic from that domain name, including sub-domains.
Method 3: Filter Out Ghost Referrers in Google Analytics
The first two techniques mentioned above will block referrer traffic that arrives at your website.
However, spammers may sometimes not send referral requests to your website. Instead, they can target your Google Analytics tracking code to trick it into recording a spam request.
These attempts will bypass filters on your website and may still appear in your Google Analytics reports.
You can filter these ghost referral spam in your Google Analytics account.
Simply log in to your Google Analytics dashboard and switch to the Admin view by clicking the gear icon in the bottom left corner.
From here, select the ‘Data streams’ option under the ‘Data collection and modification’ section.
This will bring the data streams connected to your Google Analytics property.
Go ahead and click on the data stream where you’d like to block spam referrers.
After selecting your data stream, you’ll see different settings.
Simply scroll down to the ‘Google tag’ section and then click the ‘Configure tag settings’ option.
Next, you will need to scroll down to the ‘Settings’ section.
From here, simply click the ‘Show more’ option to view more settings.
You should now see more settings.
Next, click the ‘List unwanted referrals’ tab.
This will bring you to the configuration screen.
Under Match Type, choose ‘Referral domain contains,’ and then add the domain you want to block next to it.
Click on the ‘Add condition’ button to add another domain if needed.
Once finished, just click the ‘Save’ button at the top right corner of the screen to save your settings.
Google Analytics will now exclude these referrals from your reports.
We hope this article helped you learn how to block referrer spam in Google Analytics effectively. You may also want to see our ultimate conversion tracking guide for beginners or how to properly set up eCommerce tracking on your website.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Jiří Vaněk
I clicked through Google Analytics to find the needed data, and I thank you for the guide on how to do it, because even with it, it took me a few minutes to actually find the information I was looking for. There really were some suspicious domains. I’ve now installed the Analytics Spam Blocker plugin you recommended, and I’ll monitor whether the data improves over time and if the traffic gets cleaned up from unwanted referrer spam.
Dennis Muthomi
As a multi site WordPress manager I’ve dealt with referrer spam before. One additional tip I’d add is to regularly review your referral sources in Google Analytics even after you’ve implemented these methods.
This will catch any new spam domains that slip through and allow you to adjust your filters or settings on the fly.
Alwin
If i click on add a new filter, i only get the option to make an “exclude” filter. I don’t see the option to select a “include” filter like in the screen shot at this article. How is that possible?
Sacha
Thank you for providing such helpful information, keep up the good work.
bilal
I think that this is not good. The best is to reject and block all these spam referrers because they cause to increasing the bounce rate. The problem is not in seeing them in the reports . The problem is how to block visitors from that spam referrers .
Thanks
Oyekunle Damola
Hello, you talked about the Regex string as ^wpbeginner.com$|^videos.wpbeginner.com$|^example.wpbeginner.com$
Other tutorials I have seen use this format -> wpbeginner\.com
So which is correct?
WPBeginner Support
Both are correct.
Admin
Michaela
This is exactly the information I have been looking for! Thank you!!!
Editorial Staff
You’re welcome
Admin
Laurent
I agree with Mickey, the easiest way to get rid of those referrer spam is to filter out in Analytics all the requests for which the hostname is not the URL of your blog. Almost all the referrer spam don’t fill up this field, leaving it empty.
Maintaining a list is painfull since there are always some new comers in the game.
Bob
I agree with Mickey, the Referral Exclusion List t seems to be a bad idea.
Martin
I agree with Mickey. You need to include valide host name in Google Analytics filters and it will block all the rest. Like that you don’t have to worry about future spam to exclude. And you certainly don’t need any plugin.
Ruth
As Mickey mentioned above, using the referral exclusion will hide the problem as visits will be treated as Direct. Please, change the recommendation to using filters instead.
/Ruth
WPBeginner Support
Thanks Ruth, we have updated the article with more accurate method of setting up filters.
Admin
Sagar Nangare
Very nice article on very important issue causing lot of damage to reporting.
Cindy Peterson
LOL I have just found out the majority of my “traffic” was spam. Sigh. Thanks for the advice. I have downloaded the plugin & added the spammers to my google analytics.
Mickey
The Referral Exclusion List tip is a bad idea; that will simply treat them as “direct” visits and continue to muck up your Analytics. The better move is to set up a filter that relies on valid hostnames and blocks the rest. Here’s a video that shows how to do it:
WPBeginner Support
Update: We have updated the article with more accurate method of creating a filter for valid hostnames.Thank you for suggesting it.
Admin