Upcoming LunaMetrics Seminars
Washington DC, Dec 1-5 Los Angeles - Anaheim, Dec 8-12 Pittsburgh, Jan 12-16 Boston, Jan 12-16

Getting More than One Requirement out of your GA Report Filter

The Problem

Do you sometimes want a second report filter at the bottom of your keyword reports?

Report Filter

I do. Every time I want to see phrases containing a particular word, but not containing branded keywords. For example, I might want to see all searches containing “conversion”, but not “lunametrics conversion.” It is a recurring theme for me.

 

The Solution

So what do you do? It’s called a Lookahead, and it comes in two versions. Positive Lookahead and Negative Lookahead. And we can chain together as many as we want.

Let’s say I want to find all keyword phrases that contain conversion and contain website but do not contain lunametrics. Here is what I’d type into the report filter:

^ (?=.*conversion)(?=.*website) (?!.*lunametrics).*$

The (?! begins a negative lookahead (must not match) and a (?= begins a positive lookahead (must match). The regular expressions inside the lookaheads can be as complex as you want. But if you just want to follow the formula I used here. . .

 

The Recipe

1. Start with ^
2. Place each word you don’t want inside a Negative Lookahead : (?!.*word)
3. Place each word you do want inside a Positive Lookahead: (?=.*word)
4. Chain together as many of each as you want
5. Finish up with .*$

Caveat

This example will match anything with “website” in it anywhere. If you want to match exactly “website” and not “websites” or “123website”, use (?=.*\bwebsite\b) instead.

http://www.lunametrics.com/blog/2008/01/16/getting-more-than-one-requirement-out-of-your-ga-report-filter/

13 Responses to “Getting More than One Requirement out of your GA Report Filter”

Robbin,

this post is the most precious/*actionable* piece of information I have read since I don’t remember when. This is just great! My boss asked this exact same question last week and I said this is not possible using GA (he will probably read this comment very soon).

Thank you for all the insightful posts you have been sharing. They are really insightful, but this one has trespassed the + 4 standard deviations :-)

Robbin says:

Daniel – I don’t get any credit. Well ok, I get a little bit. For the new year, I took our whole staff out and said, “Let’s toast to me, because I was smart enough to hire you. “

This was written by John Henson. He is a senior web analyst here at LunaMetrics, and I will remind him to put his name on his posts.

Ben Krull says:

Brilliant! I think I could spend a whole lifetime and never fully understand regular expressions. Thanks

Very many thanks for this info. I couldn’t get it to work at first because I left a space after ^.

Also, looks like we could expand this easily to include searches for say “adam” OR “eve” by using the pipe operator, eg ^(?=.*adam|eve).*$, right?

But how could the search be refined to an exact keyword match as opposed to broad match?

John says:

Eamonn,

^(?=.*(adam|eve)).*$ I think this would be correct for what you want. So if you wanted everything that had “garden” “serpent” and either “adam” or “eve” then ^(?=.*(adam|eve))(?=.*garden)(?=serpent).*$

For anywhere you want an exact match, use (?=.*\beve\b) this would match “eve” but not “evening” and not “eve1″ (it would also match “+eve+”) As long as the letters “eve” are not surrounded by letters or numbers

-John

Eamonn says:

Thanks John,

(?=.*\beve\b) matches “eve” but I would get results like “adam and eve”

I’m trying to find the code such that only [eve] is returned. (an exact match with no other terms)

John says:

Eamonn,

^eve$ should give you what you want.

Aaron King says:

John,

Your last two posts have inspired me to move your blog up significantly in relevance when it comes to my RSS reader.

Great work dude!

Aaron

[…] Getting More than One Requirement out of your GA Report Filter | Increasing your Website’s Con… Regular expression filtering in google analytics reports (tags: google analytics regularexpressions regex) […]

Ophir Cohen says:

Oh, this one is a real beauty. Of course now with custom segments we can also do this from other directions – but still…fantastic.

Windfery says:

has anyone tried this recently? I don’t think it’s supported anymore.

John says:

Lookaheads are not usable anymore with the in-line filter boxes.

But there is now an option for “Advanced Filter” that you can use to create a filter with multiple conditions.