It’s the mid­dle of the night…you wake up in a cold sweat…you think back to that great Dis­cover analy­sis that you pre­sented to the entire com­pany which cowork­ers praised, change the approach of major global ini­tia­tives, and appeared to be the answer to world peace. And then the ques­tions start to hit you…did I seg­ment cor­rectly when gen­er­at­ing that data? Was that an AND or an OR state­ment that I used in my seg­ment? Did I cor­rectly make all of the dif­fer­ent state­ments work together?

Well, you’re not alone. Detailed seg­men­ta­tion is a crit­i­cal part of Dis­cover func­tion­al­ity and to seg­ment cor­rectly you need to know how to work with cri­te­ria and to prop­erly struc­ture each con­di­tion to cor­rectly iden­tify the seg­ment that you want. Here are a few details on work­ing with AND/OR state­ments using the Dis­cover seg­ment builder. Launch Dis­cover and open the seg­ment builder by click­ing on the plus icon which shows in the bot­tom right of the seg­ments pane.

AND or OR For a Sin­gle Con­tainer
With the seg­ment builder open, let’s start with pulling over a con­tainer onto the seg­ment can­vas (in this case I’m using a visit con­tainer) and click on the link in the con­tainer that says “Click here to define Visit”. This will bring up the Rule Builder which allows you to apply cri­te­ria to the con­tainer. Under the Rule List you will be able to list one or mul­ti­ple cri­te­ria. Being that we are talk­ing about AND/OR state­ments you’ll need to add mul­ti­ple cri­te­ria. Notice that as you add cri­te­ria you have a nice “AND” or “OR” that appears next to each row. This is con­trolled by the Match drop­down at the top of the Rule Builder. When you choose “ALL of the rules” you are cre­at­ing an AND state­ment between each of the cri­te­ria and when it is set to “ANY of the rules” you are cre­at­ing an OR statement.

In the exam­ple of my screen­shot I am using an AND con­di­tion which would result in a seg­ment that con­tains vis­its that are vis­it­ing for the first time, were referred from Bing, and spent 5 to 10 min­utes on the site.

AND and OR For a Sin­gle Con­tainer
Now, what if we wanted to use the same seg­ment but look­ing at refer­rals from Bing OR Google? Look­ing at the Rule Builder inter­face you can quickly tell that you are only able to cre­ate an AND or OR state­ment between the cri­te­ria. So how would I seg­ment for first-time vis­its that spent 5 to 10 min­utes on the site and came from Bing OR Google? Answer: use mul­ti­ple con­tain­ers! So hit “OK” on the rule builder and let’s move on to the next section.

AND/OR for Mul­ti­ple Con­tain­ers
When work­ing with mul­ti­ple con­tain­ers keep in mind that you will now be work­ing with two sets of AND/OR state­ments. First, there is the con­di­tion that you des­ig­nate within the con­tainer. Addi­tion­ally, you have another drop­down above the seg­ment can­vas that spec­i­fies the con­di­tion between con­tain­ers. Select­ing “ALL of the fol­low­ing occurred” cre­ates an “AND” between con­tain­ers and select­ing “ANY of the fol­low­ing occurred” cre­ates and “OR” between containers.

Note: If you have also used the seg­ment builder for Data Ware­house or ASI you will likely notice that these other seg­ment builders, while sim­i­lar, do not have this drop­down. In these tools keep in mind that the con­di­tion between the outer con­tain­ers is always OR.

As I men­tioned in the last sec­tion, you can’t do a mix of AND and OR con­di­tions with a sin­gle con­tainer; how­ever, we can mix mul­ti­ple con­tain­ers to cre­ate the same results. So, if I wanted first-time vis­its that spent 5 to 10 min­utes on the site and came from Bing OR Google I could cre­ate two visit con­tain­ers that each con­tains the same cri­te­ria but with the refer­rer in one set to Bing and in the other set to Google. Then the final step is to adjust the drop­down to “Any of the fol­low­ing occurred”. Here is what the final seg­ment would look like:

AND/OR for Con­tain­ers within Con­tain­ers
Using the seg­ment builder you can place con­tain­ers within other con­tain­ers. When doing this the con­di­tion between the con­tain­ers is AND. Here is an exam­ple of a seg­ment where I want to look at vis­its that added prod­uct 12345 to the cart and pur­chased prod­uct 12345:

You’ll notice that even though the con­di­tion in the drop­down is set to “Any of the fol­low­ing” (which is an OR con­di­tion) the inner con­tain­ers are still AND. The drop­down only applies to the outer con­tain­ers. If you did want to cre­ate an OR for this seg­ment (vis­its that added OR ordered prod­uct 12345) then, sim­i­lar to the Bing/Google exam­ple ear­lier, you could move one of the page view con­tain­ers over to a sec­ond, outer visit con­tainer. The con­di­tion in the drop­down would then apply and you could adjust it to be OR.

In the case that you have cri­te­ria in the outer seg­ment and in the inner seg­ment the con­di­tion is still an AND. This applies wither the con­di­tion in the Rule Builder for the outer con­tainer is AND or OR.

This seg­ment would include vis­its where the visit num­ber is 1 AND (you can’t see the AND in the screen­shot but it is in the Rule Builder) a refer­ring domain of bing​.com AND had a sin­gle page with a cart addi­tion and a prod­uct of 12345.

Well, I hope you enjoyed that bit of fun. If you have ques­tions or com­ments use the response forum below or shoot me a tweet (@willeitner). I’ll tweet out to my fol­low­ers 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.