How To Use More Than One Include Filter (without losing data)
aka “Catching the Purple Squirrels”
Google officially recommends not to use more than one include filter, because it can lead (rather unintuitively) to excluding all the data in an Analytics profile.
“Adding more than one Include filter to a profile can cause data to not appear in your reports. To allow data to populate your reports again, we recommend assigning a maximum of one Include filter to each of your profiles.”
But sometimes using more than one include filter is the only way to catch the purple squirrels. Let me explain.
When One Include Filter Isn’t Enough
A reader sent us this question:
“I’d like to create a GA profile and to apply one filter to include only the SE organic traffic coming to a specific part of my site…. For example, all the traffic coming from SE organic to www.example.com/mydir/”
Unfortunately, even though he’d thought outside the box and (very creatively!) tried to use a single include filter based on Campaign Target URL, he was not successful.
In this case, a single include filter will simply not suffice. He needs one include filter for the traffic medium (organic) and another include filter for the set of pages visited (the specific subdirectory).
Why Using More Than One Include Filter Can Exclude All Your Data
So what’s the problem with using more than one include filter? Why does Google recommend against it? Here are two helpful tips to remember:
- When it comes to filters, “include” means include only (i.e., exclude everything else)
- When applying multiple filters, imagine the word “and” between them
If you remember those two things, then applying filters like the following will obviously exclude all your data:
“Include only squirrels AND include only dogs AND include only cats…”
It all boils down to the types of data you’re trying to include. Ask yourself, can members of one type be members of another type, or are they mutually exclusive?
Why Using More Than One Include Filter Can Be Okay
Our reader is trying to include two types of data that are not mutually exclusive. He needs to include data from organic search traffic and data from pages in a specific subdirectory. Viewed another way:
- Data from one subdirectory is our set of squirrels (a different subdirectory could be dogs, etc.)
- Data from one medium is our set of purple things (a different medium could be yellow things, etc.)
And here we want data that belongs to both sets, i.e. the elusive purple squirrels.
In this case we absolutely can use two include filters. We can say “include only purple things and include only squirrels” because then we’ll end up with the purple squirrels.
How To Catch the Purple Squirrels
First, the standard warning. Don’t apply new filters to existing profiles! Always create a new profile or use a test profile to “test drive” new filters and make sure they get the data you want.
Now create your two include filters. Navigate to the new/test profile, then go to the Filters tab and click +New Filter.
To include only organic traffic, create a custom filter. Choose “Include” and Filter Field “Campaign Medium” and Filter Pattern “organic” (don’t include the quotes). Click Save.
Then create another filter to include only traffic to a subdirectory. You actually have two options here: One way is to create a predefined filter. Choose “include only” and “traffic to the subdirectories” and “that are equal to” and then enter the subdirectory, such as /mydir/.
Predefined vs. Custom Filters
The drawback to the predefined filter is that it does not recognize regular expressions. (Say what? Check out our free e-book for an easy intro to regular expressions.)
So the other way to include only traffic to a subdirectory, and the only way if you need to use regular expressions, is to create a custom filter. Choose “Include” and Filter Field “Request URI” and Filter Pattern ^/mydir/.
In a custom filter I can use special characters from regular expressions, like the caret (^). The caret means “starts with”. So I enter Filter Pattern ^/mydir/ if I want to match pages like /mydir/abc.html but not /sub/mydir/abc.html. To match /mydir/ at any level, just leave the caret off.
And voilà! With an include filter for organic traffic and an include filter for /mydir/, our reader has a new profile containing exactly the data he wants.
But one more thing before I go…
Catching Squirrels and Dogs
Remember how I said you can’t include only squirrels AND include only dogs? We can actually work around that, using custom filters.
What I’ll do is create a custom filter that says “include squirrels OR dogs” because I can use a special character from regular expressions called the pipe (|). The pipe, or vertical bar (found above the Enter key on most keyboards), simply means “OR”.
To include traffic to /mydir/ or /mydir2/ create a custom filter, choose “Include” and Filter Field “Request URI” and Filter Pattern /mydir/|/mydir2/.
To match pages that have to start with /mydir/ or /mydir2/, change the Filter Pattern to ^/mydir/|^/mydir2/.
What are some other issues you’ve had with filters? Have you discovered creative ways to get the data you need? Let me know in the comments.








Great article! It is also worth considering that there is a 255 character limit on a profile filter, when trying to catch squirrels AND dogs
Thanks, Cristina! Good point about that character limit. I’ve run up against it quite recently, trying to include a large range of IP addresses. Did not solve it satisfactorily, even using GA’s IP address tool.
Just had to explain this to someone… agreed, turning it into an english statement often makes things easier for everyone. I usually tell people they can literally “read” their filters as follows:
Exclude = “do not show me”
Include = “show me only”
A subsequent filter (the cascading logic) = “, and of that group,”
So just as you pointed out, if you read three include filters in a profile (first squirrels, then dogs, then cats), the english statement would be:
“Show me only squirrels, and of that group, show me only dogs, and of that group, show me only cats.”
That is a perfect explanation. Love it. Thanks, Mitch!
OK, with the 255 character limit and include filters, there is a way around this. Suppose you wanted to include Cats, Dogs, Mice, Horses, Sheep, Iguanas, Koalas, Hyenas but no other animals. What you can do is set up search and replace filters to replace, e.g. “Cats” with “Include/Cats”, and so on for all the other animals. Then setup an include filter to include “include”. Obviously you don’t want your reports to say “include/cats” etc so you then set up another search and replace to replace “include/” with “/”.
Great idea, Nick. And it will work for any field that is available in search and replace filters. I thought about trying something like this for my IP address problem, but it’s not available (probably related to the Terms of Service which prohibits storing personally-identifiable info like IP addresses in your GA data).
Thanks for Posting such Valuable information.Kindly Keep Posting in it.
For all of the great tools Google provides, I often find that they fall down when it comes to explaining the finer details. This post is a great example of that.
Prior to reading this, the only way I knew of getting the effect of multiple include filters on a profile was to layer exclude filters on top of each other. If you exclude everything else, then you are tracking only what you want. Tedious.
Today I tried implementing the pipe method, but I’d like to verify one thing with you:
If I apply a custom filter of /squirrels/|/dogs/ to a profile named Animals I see in the Park, should I expect the number of visits in that profile to equal the number of visits I see in the Squirrel Profile (which is using an include filter of /squirrels/) + the number of visits I see in the Dogs Profile (which is using an include filter of /dogs/)?
Hi Anthony, since your filters are including only certain pages, you can add the pageviews for Squirrels and the pageviews for Dogs. That total should equal the pageviews for the profile that combines Squirrels and Dogs (assuming the URLs are truly mutually exclusive and we don’t have a URL like /squirrels/dogs/will-they-ever-get-along.php).
But you can’t add the visits together, because if someone views a /squirrels/ page and a /dogs/ page in the same visit, then you’d have 1 visit in the combined profile, 1 visit in the Squirrels profile and 1 visit in the Dogs profile. Hope that helps!
What’s the difference between “equal to” and “contain” and “begin with”. Ex, I want to track subdirectory /abc on domain.com/abc. Which option I should use?
Currently I think and use the “that contain” option in Predefined filter. Is that OK?
In a Predefined filter, “equal to” means the pattern you enter must match exactly – nothing can come before or after it. And “begin with” means nothing can come before the pattern you enter, but anything can come after it. The “contain” option means anything can come before or after the pattern you enter. Entering /abc or /abc/ using the “contain” option may or may not work for you depending on the variety of URLs you track on your website. Check your Content reports and filter the table by entering /abc to see if any URLs appear that you do not want to include. I prefer to create a Custom Include filter for Request URI, where I can use regular expressions to describe all the URLs I want to include (and I always double check my pattern in the Content reports).