Home | News | WP Beginner News & Tutorials | How to Block WordPress Referrer Spam in Google Analytics

How to Block WordPress Referrer Spam in Google Analytics

Are you getting a lot of referrer spam in your Google analytics? Referrer spam is a way to pass fake referer information to websites. These spammy links then appear in a users analytics and can lead you to click on malicious websites. In this article, we will show you how to effectively block WordPress referrer spam in Google Analytics.

Getting Started With Google Analytics

If you are not using Google Analytics on your WordPress site, then you should check out our guide on how to install Google Analytics in WordPress .

Google Analytics is an awesome free tool that allows you to see how users interact with your website. You can see which pages users are visiting, track clicks on links , run split tests , and much more. See this beginner’s guide on how to use Google Analytics for your WordPress site .

For those of you who are already using Google Analytics, let’s fix the referrer spam problem in your Google Analytics reports.

What is Referrer Spam?

We all want our websites to be noticed. It makes us happy when other websites link to our articles. Referral spammers take advantage of this desire by sending fake referer URL with automated scripts to thousands of websites.

This URL then appears in your Google analytics or any other stats service you are using as referrers. Considering the fact that they affect millions of websites, it is likely that many users may want to explore these sites when they see them in their referral reports.

Referral Spam

Why You Need to Worry About Referer Spam

Some might say that referrer spam is quite harmless unless you click on the links. Well let’s assume that you won’t click on those links, there are still other downsides.

If you are small or medium sized website, then referer spam can ruin your sites analytics reports.

If you decide to sell your website and share this report with interested buyers, these spam links can leave a bad impression on them.

How We Deal With Referrer Spam?

We use Sucuri to monitor our website’s security. Sucuri not only only protects our website against malware and trojans, it also blocks referrer spam.

Sucuri Website Firewall blocks most known bad referrals by default. Their team is always adding new referral spammers to the list and actively monitoring their behavior.

Blocking Referrer Spam in WordPress Using Plugin

There are several WordPress plugins that can help you keep referrer spam to a bare minimum. These plugins use web services that are actively monitoring referral spam websites and use that list to block referral spam.

First thing you need to do is install and activate the SpamReferrerBlock plugin. Upon activation, you need to visit Settings » Spam Referrer Block to configure the plugin.

Custom Blacklist

On the plugin’s settings page, you will see a text area to create your own custom blocking lists. Below that you will see the list of sites this plugin is actively monitoring and blocking. You can update this list with the most up to date version by clicking on the download from server button.

Download blacklist or upload yours

If you see a referrer spam link in your Analytics account that is not listed on this page, then you can add it to the custom blacklist. Click on the save button and plugin will start blocking it.

You can also share your custom blacklist with the rest of the internet community by clicking on the upload to server button at the bottom of the page.

Block Ghost Referrals Using Google Analytics Filtering

Despite implementing these solutions, you will still see some referrer spam in your Analytics reports. These websites are not visiting your site at all, so Sucuri or any other tool cannot block them.

They are sending their requests directly to Google Analytics using your UA Tracking code. This tracking code is used by Google Analytics to identify your website. Most site owners add it to their WordPress site’s footer or header section. Anyone can look at this code and use the UA tracking id to generate referrer spam.

Here is how you can block such websites in Google Analytics itself. Login to the Google Analytics account and then go to Audience » Technology » Network.

You will need to select Hostname as primary dimension and expand the results to Monthly.

finding hostnames for spam referrals in Google Analytics

You will see a list of hostnames with many spam hostnames in the list. You need to only note down the valid hostnames for your website. For example, www.wpbeginner.com, wpbeginner.com, videos.wpbeginner.com, are all valid hostnames for our website.

Now that you have your valid hostnames sending, the next step is to create a filter that only includes the valid host names.

Click on the Admin view and then click on Filter.

Filter menu in Google Analytics admin

This will bring you to the filter screen, where you will click on the New Filter button to get started. You need to select ‘Custom’ as your filter type and then click on Include.

Creating a hostname filter in Google Analytics

You will enter valid hostnames as filter pattern using Regex string. The format is simple, you will add a ^ sign before each hostname and a $ sign after it. Use | sign to separate hostnames.

^wpbeginner.com$|^videos.wpbeginner.com$|^example.wpbeginner.com$

Finally, click on the save button to apply the filter. Give it at least 24 hours before you can notice any changes in Google analytics reporting.

Blocking Common Spammers Using Google Analytics Filter

You can also block common referral spammers using Google Analytics filters as well. Create a new filter and select Exclude as the filter type. In the filter pattern add the hostnames of the common referral spammers. Here are some of the most notorious referral spam sites in one filter:

semalt.com|buttons-for-website.com|blackhatworth.com|anticrawler.org

Don’t forget to click on the save button to apply the filter.

We hope this article helped you learn how to block WordPress referrer spam in Google Analytics. You may also want to see our list of 7 best analytics solutions for WordPress users .

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 .

To leave a comment please visit How to Block WordPress Referrer Spam in Google Analytics on WPBeginner .

http://www.wpbeginner.com/category/wp-tutorials/

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.