Cleaning Up Analytics – How to Exclude WordPress Preview Traffic

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:

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!


  1. Stephanie

    You can also do it with PHP conditionals

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

    • Matthew Diehl

      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.

Leave a Reply

Your email address will not be published. Required fields are marked *