Google Analytics filtering for WordPress previews

When you have a WordPress site (or many), you might be inadvertently padding your Google Analytics Pageview data. When you “Preview” a post or a page in a browser, you are adding a pageview to your Google Analytics data. This will give you data that’s not accurate and can prove to be misleading as you make decisions about your site in the future.

The best way to remedy this situation is to create a “Filter” within Google Analytics. To do this you’ll need to go to your Google Analytics setting for your WordPress site.

  1. Click on “Filters” and then “+ New Filter”
  2. Select “Create new Filter for Profile”
  3. Name your filter – I called mine “WordPress Preview”
  4. For the Filter Type, select “Custom Filter”
  5. You’re going to want “Exclude” this traffic from your reports
  6. The Filter Field should be “Request URI”
  7. For the filter pattern, use the regular expression: “/p=[0-9]+&preview=true”
  8. Click “Save”

That’s it. Now all traffic that is previewing a post or a page will not get counted in your Google Analytics data.