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.
About Dorcas Alexander
Dorcas Alexander is a Digital Analyst working with Google Analytics. Her path to LunaMetrics included stints in ad agency creative, math, computer science, language technology research, and corporate training. She loves to learn and teach what she’s learned. One of the top-rated tournament Scrabble players in Pennsylvania, Dorcas has an insatiable drive to compete and win. “Impossible” is not in her vocabulary.