Removing Bad (Spam) Traffic From Google Analytics

fake-spamIf you use Google Analytics, you’ve probably noticed in the past few months a ton of fake traffic in your website analytics. Traffic from referrals like, or (and other obviously legit sites). You’ll notice this traffic has a zero session view time and only visits the root of your site. Actually, “visits” isn’t even the correct term, because to my knowledge, these site are just loading the Google Analytics javascript with your tracking code. I guess they believe it’s an easy way for people to see their site “giving” you traffic, then you visit them – and who knows what happens next.

Below are the steps I use to create a new segment in Google Analytics. You can use this segment instead of the “All Sessions” default.


1. Add a new segment:


2. Give it a name:

(I called mine “Real Traffic”, since I’m attempting to keep only actual user visit data).


3. Go to the “advanced” area to start adding:


4. Let’s add the first rule to remove data with blank hostnames:

Make sure Sessions and Include is set, then select Hostname and Matches Regex. We’re including multiple domains (your domain and others you want to include (like Be sure to add your domain to this list! Note: the “|.*” is RegEx for and + starts with.


5. Second and last rule:

Now the second rule has 2 conditions and is removing the other part of the bad / spam data using referral sources. This is where the action happens and starts to really clean the bad fake traffic. Make sure to set Sessions to Exclude, and use “and” in between the two parts of the condition.



That should be it. Save your segment and see if it makes a difference. I prefer this method over filters since it doesn’t remove any data.

In some of my test sites, I’m finding 96% of the traffic is fake (below is a comparison).



For reference, here are the sites I’ve found so far to be junk and I’m excluding:

Edit 7/15 - 2 more additions to add:

Edit 8/3 - another awesome referrer:

Removing Bad (Spam) Traffic From Google Analytics

Google Analytics Custom Report Filters – RegEx

google_analytics_logoIf you’ve noticed, Google Analytics doesn’t seem to allow you to filter on standard reports using multiple dimensions if you’re only showing one. You can easily create a custom report and add your filters using multiple dimensions and only show one. However, many users get scared by the RegEx option under Filters (the only other choice is Exact). It’s not that complex, below is a simple example showing multiple filters using a simple RegEx ‘contains’. Continue reading “Google Analytics Custom Report Filters – RegEx”

Google Analytics Custom Report Filters – RegEx