How to Block Website Referral Spam

Posted on 07/01/2020 by Ben Wood

Website referral spam can alter your Google Analytics data and slow your website down. Learn how to block website referral spam to create a better user experience and cleaner data.

If you notice a spike in referral traffic in your Google Analytics account, you might conclude that more people are clicking through to your website. However, the harsh reality is that there is a good chance that this spike may be the result of visits from spammy referral sources.

Website referral spam has been a problem for years and occurs when a spammer uses a URL (that’s usually fake) to make requests to your website without actually visiting it. This means they appear in your Google Analytics acquisition report often in the hope that you’ll then click through to visit their URL.

This form of artificial traffic to websites can’t be considered to be real visitors because they are not genuinely interested in your products and services.

At Hallam, we regularly have to inform our clients that their website traffic has not been as high or as valuable as they believe.

Spam Robot

Why Do I Need to Exclude Website Referral Spam?

There are two reasons why excluding referral spam is important for your website. Firstly, referral spam will skew your Google Analytics data and result in inaccurate reporting of your website’s performance. Secondly, visits from these spammy referral sources could potentially overload your server. This can lead to slow page loading times, which then results in a poor user experience, which will frustrate genuine visitors.

What Website Referral Spam Domains Do I Need to Lookout For?

There are several spammy websites that you need to look out for and block from your website and your Google Analytics data.

Here’s a list of some common referral spam domains to look out for and exclude from your website:

To take a look at what referral traffic your website has been receiving, first, log into your Google Analytics account. Once in Reporting, click Acquisition, then select All Traffic and Referrals.

As you can see from the example below, this particular website is getting a significant volume of traffic from spammy referral domains such as and

Spammy Referral Traffic in Google Analytics

How Do I Block Website Referral Spam Traffic from My Website?

There are two ways you can do this. You can either edit your domain’s .htaccess file or apply Google Analytics filters.

Editing your domain’s .htaccess file

The most effective way to block your spam referral traffic is through a .htaccess (hypertext access) file. This configuration file is used to control your server. It can be instructed to block spammy visits by domain or IP address.

This method not only blocks referral spam domains from your website but it also removes them from your server as well as preventing your website from being overloaded and slowing down.

For example, if you want to exclude Semalt and, add the following command to your website’s .htaccess file:


RewriteCond %{HTTP_REFERER} semalt\.com [NC,OR]

RewriteCond %{HTTP_REFERER} buttons-for-website\.com [NC,OR]

RewriteRule .* – [F]

The ‘NC’ makes the rule case insensitive, so even would still be caught by the block. The ‘OR’ is added to all entries to indicate that multiple referrers are to be blocked. The bottom line dictates what happens when a domain tries to access your site and is denied. The ‘F’ indicates a fail and means the referrer will receive a 403 error.

Be very careful inputting commands in the .htaccess file. If you put one character of the code in the wrong place or accidentally type a double space, it could take your whole website offline. In the above example, note the use of the slash before the .com as this is important. If you have a WordPress website, you can download the WP-Ban plug-in to help guide you through the process. Alternatively, seek advice from your website developer.

You might wonder – what’s the difference between a .htaccess file and a robots.txt file? A robots.txt file is used to issue crawling directions to search engine bots, while the .htaccess file allows you to set up strict commands, including fully blocking certain users.

Tip: The folks over at Perishable Press have put together a comprehensive referred blacklist that you can use in your own .htaccess file. Make sure you check it through and use it with caution to ensure it doesn’t block or break your site. If you’re unsure, it’s best to build your .htaccess file from scratch.

Applying Google Analytics Filters

The second method of blocking spammy referral traffic is through applying filters to your Google Analytics account.

Filters within Google Analytics are not only great for excluding domains and IP addresses but also come in handy for excluding internal or agency visitors that are considered non-genuine visits to your website.

Here we’ve described how to filter out spam referral traffic using the campaign source (or domain) of the referrer.

1. Login to your Google Analytics account

2. Navigate to the Admin section

Blocking spam in analytics


3. Go to Filters and Add Filter

4. Select ‘Create new Filter’ and give the filter a name

5. Select ‘Custom’, ‘Exclude’ and then ‘Campaign Source’ from the Filter field dropdown

6. In the ‘Filter Pattern’ field, enter the domain of the referrer you want to exclude but be very careful that you’ve investigated the referrer and are confident that it’s spam/bot traffic before you filter it out of your stats. You can also use a regular expression to exclude multiple referrers in one filter. Google gives this example of a referral filter regular expression:


7. Then click ‘Verify this filter’ to see how it will affect your data going forward, based on your most recent traffic.


Filtering internal traffic and specific IP addresses from your data is very simple to do. Just follow these steps:

  1. Instead of selecting Custom as your filter type, select Predefined.
  2. Set filter to ‘Exclude’, ‘Traffic from IP addresses’, ‘that are equal to’ and then in the field below enter the IP address to be blocked. You can find out the IP address of the internet service you’re currently connected to by going to Google and typing ‘What’s my IP?’
  3. You can also use regular expressions here if you want to exclude an IP and it’s subnets. See Google’s article on this for more information:

Adding Spam Filter


While applying filters is great for reporting purposes, remember that they won’t prevent spam bots from visiting your website. The filters will just exclude the visits from the Google Analytics data. For best results, you should also block these domains through your website’s .htaccess file.

Filters will also not impact data retrospectively, so only traffic captured from when the filter was implemented will be affected.

Do you know any more spammy referral domains that you wish to name and shame? Submit your comments below, we’d love to hear from you!

Want to learn more about websites?

Have you just learned something new?

Then join the 80,000 people who read our expert articles every month.
  • By signing up to this form I agree, that Hallam may store my data and may contact me using the email address I have provided with promotional emails about products, special offers, and other information which may be of interest. Please also read our privacy policy. You can revoke your consent at any time

  • This field is for validation purposes and should be left unchanged.

If you need help with your Analytics don't hesitate to contact us.

Enjoy this article?

Subscribe for weekly insights

How to Block Website Referral Spam

Let’s thrive together

Get in touch to take the first step.

Contact us