It’s the middle of the night…you wake up in a cold sweat…you think back to that great Discover analysis that you presented to the entire company which coworkers praised, change the approach of major global initiatives, and appeared to be the answer to world peace. And then the questions start to hit you…did I segment correctly when generating that data? Was that an AND or an OR statement that I used in my segment? Did I correctly make all of the different statements work together?

Well, you’re not alone. Detailed segmentation is a critical part of Discover functionality and to segment correctly you need to know how to work with criteria and to properly structure each condition to correctly identify the segment that you want. Here are a few details on working with AND/OR statements using the Discover segment builder. Launch Discover and open the segment builder by clicking on the plus icon which shows in the bottom right of the segments pane.

AND or OR For a Single Container
With the segment builder open, let’s start with pulling over a container onto the segment canvas (in this case I’m using a visit container) and click on the link in the container that says “Click here to define Visit”. This will bring up the Rule Builder which allows you to apply criteria to the container. Under the Rule List you will be able to list one or multiple criteria. Being that we are talking about AND/OR statements you’ll need to add multiple criteria. Notice that as you add criteria you have a nice “AND” or “OR” that appears next to each row. This is controlled by the Match dropdown at the top of the Rule Builder. When you choose “ALL of the rules” you are creating an AND statement between each of the criteria and when it is set to “ANY of the rules” you are creating an OR statement.

In the example of my screenshot I am using an AND condition which would result in a segment that contains visits that are visiting for the first time, were referred from Bing, and spent 5 to 10 minutes on the site.

AND and OR For a Single Container
Now, what if we wanted to use the same segment but looking at referrals from Bing OR Google? Looking at the Rule Builder interface you can quickly tell that you are only able to create an AND or OR statement between the criteria. So how would I segment for first-time visits that spent 5 to 10 minutes on the site and came from Bing OR Google? Answer: use multiple containers! So hit “OK” on the rule builder and let’s move on to the next section.

AND/OR for Multiple Containers
When working with multiple containers keep in mind that you will now be working with two sets of AND/OR statements. First, there is the condition that you designate within the container. Additionally, you have another dropdown above the segment canvas that specifies the condition between containers. Selecting “ALL of the following occurred” creates an “AND” between containers and selecting “ANY of the following occurred” creates and “OR” between containers.

Note: If you have also used the segment builder for Data Warehouse or ASI you will likely notice that these other segment builders, while similar, do not have this dropdown. In these tools keep in mind that the condition between the outer containers is always OR.

As I mentioned in the last section, you can’t do a mix of AND and OR conditions with a single container; however, we can mix multiple containers to create the same results. So, if I wanted first-time visits that spent 5 to 10 minutes on the site and came from Bing OR Google I could create two visit containers that each contains the same criteria but with the referrer in one set to Bing and in the other set to Google. Then the final step is to adjust the dropdown to “Any of the following occurred”. Here is what the final segment would look like:

AND/OR for Containers within Containers
Using the segment builder you can place containers within other containers. When doing this the condition between the containers is AND. Here is an example of a segment where I want to look at visits that added product 12345 to the cart and purchased product 12345:

You’ll notice that even though the condition in the dropdown is set to “Any of the following” (which is an OR condition) the inner containers are still AND. The dropdown only applies to the outer containers. If you did want to create an OR for this segment (visits that added OR ordered product 12345) then, similar to the Bing/Google example earlier, you could move one of the page view containers over to a second, outer visit container. The condition in the dropdown would then apply and you could adjust it to be OR.

In the case that you have criteria in the outer segment and in the inner segment the condition is still an AND. This applies wither the condition in the Rule Builder for the outer container is AND or OR.

This segment would include visits where the visit number is 1 AND (you can’t see the AND in the screenshot but it is in the Rule Builder) a referring domain of bing.com AND had a single page with a cart addition and a product of 12345.

Well, I hope you enjoyed that bit of fun. If you have questions or comments use the response forum below or shoot me a tweet (@willeitner). I’ll tweet out to my followers if I make any updates to the post.

7 comments
Fei Hsu
Fei Hsu

This is great post! How about the usage of Contains, and Contains All Of, or Starts with? I wanted to include a condition if an s.prop has ANY value at all on a page. The result seems to be different than what I specified. Can you provide some insight?

Peter
Peter

Haha, I can indeed relate to the first paragraph of your post. Great article Kevin! Peter

John Stansbury
John Stansbury

Kevin, Great post. Discover's segmentation engine is one of the the most powerful aspects of a truly great application. If the Marketing Channels reports could use Discover's segmentation approach rather than the current rule basis, I'd be ecstatically happy.

Jessica P
Jessica P

What about the "contains one of" option. I actually use this quite often to do an AND and OR segment without dealing with true nesting. I just space-delineate each keyword. Using your example, it would look like: Visit Bucket where: Referring Domain contains one of: bing google AND Time spent per visit equals: 5 to 10 minutes AND Visit Number equals: 1

Jesse B
Jesse B

This is a very cohesive and complete explanation of AND and OR statements in Discover. Thank you very much!

Adam Greco
Adam Greco

Great post! This definitely helps as a reference for one of the hardest parts of Discover. Thanks Kevin!

Kevin Willeitner
Kevin Willeitner

Good observation Jessica P. You can use the “contains one of” approach in some cases but there are limitations. For example, if I was the analyst for an outdoors retailer and I used the “contains one of” approach I would potentially also include visits from “climbing.com” being that “bing.com” is included in “climbing.com”. In this case you would be including too much data in your segment. To verify if this is happening in your case, pull up a referring domain report and search for “bing.com” to see what additional domains you may be unintentionally including, if any. Another case to be careful with is if we wanted an OR between multiple phrases (like segmenting on visits that visited pages named “Home Page” OR “Account Summary”) then you would not be able to use the “contains one of” approach being that the values themselves contain spaces. The individual words would be used rather than the phrase as a whole. I hope that helps.