PHPMatters Help You Better Hosting Your PHP-based Sites
How to Deal With WordPress Referrer Spam for Clear Traffic Reports

How to Deal With WordPress Referrer Spam for Clear Traffic Reports

Referrer spam is a well-known Black Hat SEO technique used to improve the website ranking of spammers. It does not harm your website directly, but can junk up and ruin the analytics reports of your website. If you want to share your website statistics for website selling and some other money-making activities, the useless data may give your interested buyers a bad impression.

In this case, we’d like to showcase the guidance about how to deal with WordPress referrer spam effectively.

General information of Referrer Spam

In fact, it is a kind of “spamdexing”, which occurs when some spam bots sending fake referrer traffic using automatic scripts to your site. Then, these fake links will be recorded in the access log of your server. Once your log is crawled and indexed by search engines, these fake referrer values might be treated as the backlinks, benefiting the online rankings of the spam websites due to the backlink-counting algorithms of search engines.

As to figure out whether you are suffering from the referrer spam, you can check out your Google Analytics account, hit the Acquisition section and click the Referrals button under the All Traffic option. Here, you can find some strange source sites like the links showed in the following image. They are exactly the fake referrer links.

Referrer Spam

Deal With WordPress Referrer Spam

To deal with this issue, we recommend three methods in the following, including the utilization of WordPress plugin, the filtering function of Google Analytics, and the modification of .htaccess codes.

Method 1 – WP Block Referrer Spam plugin

This plugin prevents the referrer spam from reaching your website automatically. Upon the successful installation of it, you need to click the Tools tab of your WordPress admin and target the Block Referrer Spam button. Then, you can enter the setting page of this plugin and can add the fake referrer links you want to block.

WP Block Referrer Spam

By default, this plugin blocks some referrer spammers based on its community-contributed list, and the list keeps updating every week. This means some common referrer links including and can be prevented from linking your site automatically. Also, you can add some custom fake links after checking your referral statistics.

Method 2 – Filtering Function of Google Analytics

This method does not block the spammers from sending referral spam to your site, but can filter the fake traffic data out of your referral statistics in Google Analytics, resulting in a clean and accurate picture of your website traffic.

For this, you need to click the Admin button after entering your Google Analytics account and then hit the All Filters button. Here, you can add a new filter with the custom filter type, and enter the fake referrer domains into the space of Filter Pattern.

Add Google Analytics Filter

After clicking the save button for the new filter, you need to wait for about 24 hours and to check the new report of your website referrers.

Method 3 – .htaccess

The modification of .htaccess code is the simplest way for the blocking of referrer spam. You only need to add the following lines of codes into your htaccess file, then, the referrer spammers will receive the 403 Error page when sending a request to your server.

Block Referrer Spam with Code

Note that the above-mentioned codes only block three referrers. You can also check the report of your Google Analytics, figure out the referrer spammers, and add the custom referrers for blocking.