How to Filter Referral Spam in Google Analytics

Ghost spam is an ancient issue.

It isn't only occurring to you. For a long time, webmasters have been plagued by ghost spam. Unfortunately, Google hasn't done much to discover a solution, other than giving an option to filter known bots and spiders.

Have you ever seen a significant increase in referral traffic in your Google Analytics (GA) account? It was a most likely bot or ghost traffic spam, which is a major annoyance because it skews your analytics. In this piece, I'll show you how to filter out referral spam in Google Analytics so you can focus on traffic that converts.

However, this does not eliminate ghost bots because they never visit or seek information from your website. Because the log of site visitors is sent directly to your GA account, you can't fix the problem by filtering using.htaccess files on apache. Here's a visual representation of an unnatural spike:

Referral spam, like comment spam, is a robotic shortcut used to generate traffic, leads, and other information with harmful purposes.

Important Points

  • Metrics and accurate reporting are harmed by bloated and false traffic.
  • The Analytics filter fix is the most simple and effective.
  • Ghost spam is an annoyance that must be constantly monitored.

Remove Referral Spam from Google Analytics

While it may not cause immediate danger, it should not be ignored. Many issues arise as a result of ghost spam, including higher server loads, traffic inflation, erroneous bounce rates and conversions, and traffic medium breakdowns. You must fight back while preserving your analytics data. It is the only method to arrive at precise findings and make sound business judgments.

Save Historical Data & Create A Copied View

This is quite crucial. To begin, you must build a new view for your newly filtered data. This allows you to keep your existing historical view and unfiltered data for cross-referencing purposes. Go to Admin > View Settings > Copy View in Google Analytics. For your convenience, a screenshot is provided below:

That newly copied view can be used to filter referral traffic, spam, and bot traffic. When GA prompts you to name the filter, you may call it whatever you want, but I recommend incorporating your website URL and a term like "Ghost Referral Spam Exclusion."

Before we continue, it's vital to note that not all bots are dangerous. Googlebot, or other spiders that explore and index your website in accordance with your robots.txt file, is one of the good guys. Bots are only harmful when they are utilized maliciously.

You must fight back while preserving your analytics data. It is the only method to arrive at precise findings and make sound business judgments.

In Analytics, How to Detect Ghost Referral Spam

Toggle your date range to 6 months or more (inception-to-present is much better) and go to Acquisition > All Traffic > Referrals > Reporting Look at the bounce rate and session time of the visits that surpass 10-15 in the chart below; this data will be an easy indicator of phoney traffic. You'll immediately see how this bogus data may significantly skew your analytics stats, especially if you're a smaller business that doesn't receive millions of sessions every month.

The domain "" is an example of true ghost spam. Have you noticed anything like this in your Google Analytics profile? It resulted in 260 bogus sessions with a 100% bounce rate and no time spent on site. This is only one of the offenders I discovered on my personal website.

Why is there ghost spam?

Ghost spam is used by malicious webmasters to attract traffic. They hope you will discover the domain in your analytics dashboard and travel to the site to find out what it is.

In a nutshell, it's basically free traffic to a landing page created just for lead creation.

Here's what you'd find to satisfy your interest without flooding that site with traffic:

If you're not sure about the domain, conduct a fast Google search for " + spam." If it's ghost-spam, there's probably a lot of documented dialogue.

Procedure by Procedure Configuration of the Hostname Filter

Setting up a filtered view by hostname is the simplest and most effective technique to exclude future bogus traffic in Google Analytics. Other guides may walk you through the process of manually filtering and excluding phoney referral traffic websites as you come across them, but the Referral Exclusion List Method is not recommended. It's also less effective because ghost spam websites and TLDs change all the time.

Almost every link and referral to your website should display your hostname. Websites such as YouTube, where you have granted the site permission to use your Google Analytics tracking ID, are a common exception. If you find in the list of referring hostnames, believe it or not, it's not legitimate.

1. Determine Hostnames

Select your date range as far back as possible in your filtered view to include all of your historical data. Then follow the steps below to get to the list of hostnames: Audience > Technology > Network > Reporting Then, filter the dimension by Hostname to see a view similar to the one below, which is from my personal website.

Your hostname should be in position one (1). The rest of these hostnames are ghost spam because I never assigned a Google Analytics tracking ID to any of them.

2 Design Your Filter Expression

It's time to write your expression now that you've discovered the valid hostnames. I swear it's a lot easier than it sounds. Simply separate each legitimate hostname with a bar, but do not begin or finish with one. Here's an illustration: " | |"

3 Insert The Filter Expression

Go to Admin > View > Filters and click the "+ ADD FILTER" button. You should be able to see the screen below. Fill in the box with a Filter Name, Custom Filter Type of Hostname, and the filter expression you defined in step 2 above. After that, all you have to do is click " Verify this filter" at the bottom to ensure that it is functioning properly, and then save.

Congratulations, you succeeded! Now all you have to do is wait a few days for new traffic and reporting data to be generated. You'll be able to detect if it's working successfully by comparing it to your previous view and ensuring that all current ghost spam is banned in your newly duplicated view. Finally, let's exclude historical ghost spam by creating a segment in Google Analytics where we can readily compare historical data.

Using Segments to Filter Referral Spam

In the top navigation, select Reporting. Then, under "All Users," select the "+ Add Segment" button. Then, give the section a name (I used "Ghost Spam Nuked"), go to Advanced > Conditions, and match the Filter, Sessions, and Include criteria (see below). Then, in step 2 above, enter your filter expression and click save.

Finally, on the Audience Overview tab, we need to construct a segment that covers all sessions for easier comparison. Click "+Add Segment" one more, leaving the checkbox " All Users" checked, and then click apply. You may now return to the Audience Overview. In the same graph, you should now observe different data in your Ghost Spam Removal Segment than in your historical All Sessions data.

Finishing Thoughts

Google Analytics is often regarded as the most reliable website metrics platform. You want your analytics data to tell a story, but when it's distorted with false positives, it's difficult to analyze and make informed judgments based on industry KPIs. For the time being, ghost spam is here to stay and will continue to be a headache for web analysts and marketers.

I don't anticipate Google to issue a general fix until the problem becomes unmanageable. In the meanwhile, we must learn how to filter referral spam in order to improve our analytics.