An assortment of thoughts.  Mostly tech related.

I ain't afraid of no ghosts! - Google Analytics and ghost referrals

Image courtesy of Sony Pictures

Image courtesy of Sony Pictures

"Bustin' makes me feel good!"

(Apologies to Ray Parker Jr and Sony Pictures)

Lately, I've been getting a lot of spam traffic to Leftfoot from fake 'ghost' referrers.  These bogus traffic sources have been contaminating my Google Analytics to the point where I've needed to do something about it.  In particular, I've been getting a lot of traffic from sites like and in the last few days, I've been suspicious about traffic from  I'm still not 100% sure about the traffic from, but given the large number of visits and the fact that they're all from Russia and to my homepage, I think I'm right to question their legitimacy, so I've taken them out too. Sorry, Russian mozilla fans.

Ben Travis from Viget Advance has an excellent post explaining how to remove ghost referral spam from your Google Analytics views and reports.  The post explains how to filter the view using regex strings both on the incoming side (so these referrers never make it to your Google Analytics dashboards in the first place), but also how to retroactively filter this traffic from your historic data using segments in your Google Analytics dashboards.


It's important to remember that whenever you add a filter to a view, it ONLY affects traffic arriving after the filter has been switched on - it doesn't filter any traffic that arrived prior. 

The other golden rule with filtering at the view level is - Always maintain a clean, unfiltered view - make the view-filtering changes to a separate view.  It's just good practice.

I've implemented both the filtering and segmenting methods following Ben's advice and using his helpful regex strings.  I highly recommend reading through Ben's article for the great background and detail and to grab the regex strings in full.

Building a segment

Segments in Google Analytics allow you to filter traffic from your reports and dashboards based on particular criteria.  In this case, we want to build a segment that filters traffic from sources matching the offending sites supposed hostnames.


I've built a traffic segment called 'No Ghosts' which shows me ALL web traffic except the ghost referrals.

To create a new segment click Add Segment, then + NEW SEGMENT and from there choose Advanced > Conditions and build something like this:

Be sure to see the post above for the full regex strings.

Be sure to see the post above for the full regex strings.

This segment filtering is fairly easy to set up, just be mindful of these small gotchas:

  1. Be sure to add them as EXCLUDE filters
  2. When combining multiple filter criteria be sure to use the OR option so that all of the rules fire the way they should
  3. Be sure to set the filter criteria to matches regex for regex expressions and I've used exactly matches for

Now, no more ghosts! least from these sources. Just make sure you have the segment selected when you view your dashboard widgets.

For fledgling sites with modest traffic, it'd be heartbreaking to implement filtering like that this as it can seriously diminish your traffic numbers, but if you're relying on these inflated bogus numbers, I'm sorry to say - you're kidding yourself about the popularity of your site.  It's like weighing yourself on the scales with one foot on the ground.  Start off on the right (left?) foot, fix it, be more confident that the traffic to your site is genuine and build it up from there.

Who ya gonna call?

Sorry.  ;) But, if we can help you with your own 'ghostbusting', or with any of your Google Analytics setup, let us know and we'll be only too happy to help you clean things up.