Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Block WordPress Referrer Spam in Google Analytics

Do you want to block WordPress referrer spam in Google Analytics?

Referrer spam sends misleading data to your website to pollute your website’s analytics reports with spam links.

In this article, we’ll show you how to block WordPress referrer spam in Google Analytics effectively.

Blocking WordPress 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.

Referral spam in Google Analytics

If you are seeing many suspicious-looking domains in your Referral reports, then they are most likely spam referrers.

Blocking these spam referrals will improve your Google Analytics reports and ensure that your data is not polluted by spam requests.

That being said, let’s take a look at how to easily block referrer spam in Google Analytics on a WordPress website.

Block Referrer Spam in Google Analytics with Sucuri

This is the easiest way to block the most common referrer spam in Google Analytics.

For this you’ll need Sucuri. It is the best WordPress security plugin and comes with the best website firewall on the market.

It blocks most common website threats including referrer spam before they even reach your website.

Sucuri

Sucuri also comes with website monitoring, malware scanner, integrity check, and dozens of security features. This protects your website against hacking, malware, and brute force attacks.

Manually Blocking Referrer Spam in Google Analytics With a Plugin

If you are not using Sucuri, then you can use this method to check referral traffic and block them.

First, you need to install and activate the Stop Referrer Spam plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Settings » Referral Spam page to review plugin settings.

Block referrer spam plugin settings

The plugin uses a referral spam blacklist published by Matomo (Formerly Piwik, an open source analytics software).

You can also enter any suspicious domains that are already spamming your Google Analytics reports.

Don’t forget to click on the Save button to store your settings.

Be careful when adding domains in the plugin settings, as it will block all traffic from that domain name, including sub-domains.

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

1. Block Unwanted Referrals in GA4

If your website is using Google Analytics 4 (GA4), then you can use the following method to remove unwanted referrals.

Simply log in to your Google Analytics dashboard and switch to the Admin view.

Select data stream

From here, under the Property column, select the Data Streams option. This will bring the Data Streams connected to your Google Analytics property.

After selecting your data stream you’ll see different settings. Simply scroll down to the Advanced Settings section and then click on the ‘More Tagging Settings’ tab.

Advanced Tagging Settings

Next, click on 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.

Block domains

Click on the Add condition button to add another domain if needed.

Once finished, click on 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.

2. Block Unwanted Referrers in Older Google Analytics

If you are still using older Google Analytics account that uses the Universal Analytics (UA Tracking) code, then you can use this method.

Simply switch to the Admin view under your Google Analytics account.

Creating a filter in Google Analytics

From here, you need to click on the Filters option under the ‘View’ column.

This will bring up the Filters screen. Go ahead and click on the Add Filter button.

Add filter button

On the next screen, you can configure your filter settings.

First, you need to switch the Filter Type to ‘Custom’ and choose the ‘Exclude’ method.

Filter spam referrers from Google Analytics reports

After that, click on the ‘Filter Field’ drop-down and select the ‘Campaign Source’ option (this is where your filter will look for the match).

Lastly, add the domains that you want to block under the Filter pattern box in the following Regex Expression format.

spamwebsite\.com|more-spam\.com|.*spammysubdomain\.com

Notice how the domain name and extension are separated by a backslash and a dot (\.), and each domain name is separated by a pipe sign (|).

The last domain in the list has a dot and asterisk (.*) before the domain name. This asterisk blocks not only the domain name but also all its subdomains.

Go ahead and click on the Save button to store your filter settings.

Google Analytics will now remove these spam referrers from your reports.

Filters don’t affect on how Google Analytics collects data on your website. They just customize reports you view in your Google Analytics dashboard.

If you need to, you can always return to the filters screen to edit or delete a filter.

Edit or delete a filter in Google Analytics

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

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

16 CommentsLeave a Reply

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

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

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

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

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

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

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

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

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.