A discussion recently came up between some Urchin Certified Partners around creating Advanced Segments that have “OR” operators and conditions. Most of us are familiar with the Google Analytics Advanced Segmentation tool that allows easy creation of “and/or” conditions. Urchin 7’s new Advanced Segments tool isn’t quite as “advanced” as GA and lacks that fancy UI, however I’ve found success in creating segments with OR conditions on the same field.
Creating Single-field Advanced Segment with OR Operations
Here is a quick screencast video of a simple Advanced Segment that identifies visits from the cities of Seattle OR Portland:
Creating Advanced Segments with Multi-Field OR Conditions
Taking this a bit further, let’s say that you want to select data from different fields with somewhat overlapping conditions. Let’s consider a scenario where I want to have a single segment that looks across Organic, CPC and Referral Mediums for certain key Sources. The condition I want to analyze is “visits from Google Organic OR CPC, -or- from referring sites that contain Gmail or ‘portland’ in the name.” OK. How do I do that in Urchin Advanced Segments? Here’s a screencast showing just that:
The trick here is that Urchin uses inclusive matching in its Advanced Segments engine. In otherwords, the each condition is restrictive to the data, i.e. if you say “only organic OR cpc mediums” then the data, after that condition, is limited to THAT set of conditions and fields you add later in the segment will only work against that now limited data. The magic of the segment I created is making the first condition “optional” using the regular expression operator for “make optional”, the “?” operator.
How You Can Do It
Try it yourself – simply use the regular expression for “OR” in an advanced segment field or nesting multiple values using the “this OR this, all of which is optional” trick.