Google Analytics Advanced Filters AND OR

Google Analytics Advanced Filters example - using AND OR regular expressions

Say you run a business energy supply website, and at some point change the URL structure.

Old URL – domain.com/energy-for-business/request-energy-quote

New URL – domain.com/business-energy/quote

At a later date you want to compare the performance of the old and new quote pages within Google Analytics.

You also have pages for domestic energy quotes (domain.com/home-energy/quote), for business energy customers (domain.com/customer-area/business-energy), and a blog with business energy posts (e.g. domain.com/blog/10-tips-to-save on-your-business-energy).

First, use the Advanced Filter function to exclude the pages you don’t want in the report:

Exclude – Landing Page – Matching RegExp – home|customer|blog

(The pipe | separates words and acts as an OR instruction, so in the example above we are excluding any landing page URL that contains the words ‘home’ OR ‘customer’ OR ‘blog’)

Next, we want to include any remaining URLs that reference ‘business’ or ‘energy’. To do so we use the following:

Include > Landing Page > Matching RegExp > business.*quote

(The .* expression acts as an AND operator, in this instance looking for any URL that contains both the words ‘business’ and ‘quote’, in any order)