Working with multiple include filters of the same type

. Posted in: Data Quality
Tags: Google Analytics, Reporting

Have you ever tried to setup a filtered view in Analytics for a whole bunch of different URLs? Only to realise that your regex pattern for including those URLs exceeds the 128 character limit? Well, I have. And I’m happy to say that there’s a pretty good workaround.

Wait, what’s the problem here?

There are several pros and cons for using URL filtered views. For example, sessions not starting on an included URL will be treated as direct traffic. On the other hand, it’s often beneficial to isolate specific sections of a site into a view on itself. But I won’t discuss this in detail in this post.

The problem I’ll discuss is that of setting up a filtered view where only specific pages are included. This is not hard under normal circumstances. Just create an Include filter, select Request URI for the filter field and enter your list of pages as a regex. Done.

The thing is that your regex must be less than or equal to 128 characters in length. So when you want to include say 50 pages where there’s no pattern in the URL, chances are that your regex will be much longer.

And even with a 128 character regex pattern, you’ll be hard at work maintaining and debugging it.

An example

This is how a simple regex filter looks like. This filter looks for all page paths that start with either /products or /services. Only pages matching that criteria will show up in the view:

Simple regex include filter

But if we wanted to include a large range of pages with very different URL patterns, we quickly run out of characters - and it also becomes difficult to read the filter pattern. Like this:


This pattern is 128 characters. It’s difficult to read. It’s prone to errors. And if you wanted to include other pages, it’s simply not possible in one include filter.

Google Analytics filters are destructive

Unfortunately, include filters in Google Analytics are destructive. Basically, they destroy all data that doesn’t match the criteria. So it’s not possible to add an additional filter to include other pages.

A better approach

Luckily, there’s a workaround. It’s not even a workaround - it’s a feature, but it’s little known. It involves using the Custom Field fields in the Google Analytics filter configuration. These are not to be confused with Custom Dimensions or Custom Vars. Custom Fields are a kind of temporary storage for filters.

The solution involves using advanced filters to:

  1. Setup advanced filters to check for patterns in page URLs
  2. Store that information in a Custom Field if the pattern matches
  3. Use one include filter to based on the Custom Field

1. + 2. Setup the page filters

Let’s start with just splitting up our example from before to make it more readable.

Create a new filter of the type Advanced and configure it like so:

Advanced filter with Custom Field

This single filter looks for page paths that begin with either /products or /services. And if a pageview on the site matches that pattern, we set the value of Custom Field 1 to include.

Then we setup the next filter - just a duplicate of this, but change the first field to ^/landing\-pages/(our\-best\-offers|why\-our\-service\-is\-better):

Advanced filter with Custom Field

…and just proceed for as long as needed with more filters like these. It should be clear that we’re already now working with some simpler filters, right?

3. Include the Custom Field

Finally, setup the actual include filter. Create a new filter of the type Include and configure it like so:

Include Custom Field

See what’s going on? We’ve not destroyed any data yet up until now. This is our only include filter, and we’re now including pages based on multiple rules (filters)!


Filtered views in Google Analytics are sometimes powerful, sometimes annoying and sometimes necessary. The approach outlined in this post is usable for those cases where one include filter on a single dimension is insufficient. It’s also usable for maintenance purposes since it allows you to create shorter, more readable filter patterns.

There are alternative options as well. For one, it’s also possible to combine look up tables or regex patterns in Google Tag Manager with a hit level custom dimension in Google Analytics - and then accomplish the same thing with a single include filter. That is entirely valid and feasible too.

In any case, there you have it. This is a pretty solid way to include (a lot) of different page URLs in a view without breaking your neck in the process.