Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Block WordPress Referrer Spam in Google Analytics

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.

How to block referrer spam in Google Analytics

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.

Google Analytics' traffic acquisition reports

From here, you’ll see different traffic sources for your website, including referrals.

Next, you can click the ‘+’ button to add another dimension.

Click plus sign to add dimensions

You will now see different secondary dimensions to filter your traffic.

Simply head to Traffic source » Session source from the dimensions dropdown.

Session source dimension in Google Analytics

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.

Check for 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

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.

Setting up the Sucuri WordPress security plugin

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.

Analytics spam blocker 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.

Open data streams

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.

Select data streams

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.

Open configure tag settings

Next, you will need to scroll down to the ‘Settings’ section.

From here, simply click the ‘Show more’ option to view more settings.

Click show more options

You should now see more settings.

Next, click the ‘List unwanted referrals’ tab.

List unwanted referrals

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.

Enter spam sources

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

18 CommentsLeave a Reply

  1. 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.

  2. 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.

  3. 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?

  4. Sacha

    Thank you for providing such helpful information, keep up the good work.

  5. 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

  6. 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?

  7. Michaela

    This is exactly the information I have been looking for! Thank you!!!

  8. 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.

  9. Bob

    I agree with Mickey, the Referral Exclusion List t seems to be a bad idea.

  10. 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.

  11. 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

  12. Sagar Nangare

    Very nice article on very important issue causing lot of damage to reporting.

  13. 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.

  14. 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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.