Cleaning Up Analytics – How to Exclude WordPress Preview Traffic

by Matthew Diehl on July 31, 2009

I don’t know about everyone else but when I am working on a post I tend to refresh the preview page constantly. This adds a bit of bloat to the Google Analytics reports for site traffic. So, here is an easy way to clean up analytics to exclude preview traffic working on a WordPress powered blog or site.

Step 1: Figure out the piece of the URL that distinguishes the preview page from all the other pages or posts on the site.

WordPress makes this one easy, here is an example of a preview page from my site: http://www.matthewsdiehl.com/?p=480&preview=true

I haveĀ bolded the key element to setting up this exclude filter. The “preview=true” sets this URL apart from the rest and is what we want to exclude from our reporting.

Now we are off to Google Analytics…

Step 2: When looking at your list of profiles in the lower right hand corner of the screen look for an option called “Filter Manager”. Looks something like this:

google analytics filter manager

Google Analytics Filter Manager



Step 3: Click the “+ Add Filter” button in the upper right hand corner of the filter list table. Looks like this:

Google Analytics Add Filter Button

Google Analytics Add Filter Button



Step 4: Set the following fields like so:

Filter Name: Exclude Preview Traffic
Filter Type [pull down]: Custom filter
Filter Type [radio buttons]: Exclude
Filter Field [pull down]: Request URI
Filter Pattern: preview=true
Case Sensitive [radio buttons]: no

Then add the profiles this filter should be applied to.

The filter should look like this:

Filter Settings to Exclude Preview

Filter Settings to Exclude Preview



Now save changes and you are done!

{ 3 comments… read them below or join the discussion }

Jeff Shariat December 30, 2009 at 5:15 pm

Needed this… Thanks!

Reply

Stephanie August 19, 2011 at 2:39 pm

You can also do it with PHP conditionals

<?php if ( is_user_logged_in()||$_GET['preview'] == "true") { echo "“; } else { ?>

Reply

Matthew Diehl August 23, 2011 at 11:20 am

Great tip Stephanie!

I like the usage of of the $_GET.

There may be a downside to the is_user_logger_in for sites that require registration to access private content though.

Still a great alternative.

Reply

Leave a Comment

Previous post:

Next post: