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Ā, best-seo-offer.comĀ 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

Force WWW & Fix Redundant Hostnames on Google / SEO

I feel the term “SEO” is completely overused, however, there are a few things you want to do besides just having great content. One is make sure your site url is consistent. is different fromĀĀ 

Google Analytics will provide you a suggestion to fix this if you’re experiencing traffic from multiple hostnames.Ā Something like:

Property is receiving data from redundant hostnames. Some of the redundant hostnames are:

This is easy to fix using your Global.asax page. Just add this to your code, replacing “yourdomain” with your actual domain. TheĀ Application_BeginRequest will catch and redirect to the altered url, also issuing a 301 to help search engines.

void Application_BeginRequest(object sender, EventArgs e)

        if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(


            HttpContext.Current.Response.Status = "301 Moved Permanently";



                    "", ""));


You could do this using web.config + rewrite, but I enjoy this method more.

Force WWW & Fix Redundant Hostnames on Google / SEO