Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How Exactly Do Containers Work in AEP Segmentation? A Deeper Look at This Powerful Feature.

Avatar

29-06-2022

Authors: @Danny-Miller @Mike-Broom 

Introduction 

Have you been in the segmentation builder, saw the option to create a container, and wondered how exactly that works? As you will see, sometimes they can be simple (quite literally), and sometimes they can be a little more complicated.

The other day, I was working on some segments for Season Ticket Holders.  We were trying to get the logic correct and noticed some fields had containers, while others didn’t.  My curiosity got the best of me, and I started diving into what containers are and how do they work? 

Containers

When creating segments in the RTCDP Segmentation Builder, there are multiple ways to group together rules to create a segment. Containers allow control over the order of execution using nested queries.

https://experienceleague.adobe.com/docs/experience-platform/segmentation/ui/segment-builder.html?lan... 

Simple Containers

Simple Containers allow users to build a nested query using Boolean logic. Once you have added at least one tile to the rule builder canvas, you can begin to add containers. To create a new container, select the ellipses (…) in the top-right corner of the tile, then select Add container (as seen in the example below).  

frederick_richard_0-1656525096934.png

frederick_richard_1-1656525096936.png

A new container appears as the child of the first container, but you can adjust the hierarchy by dragging and moving the containers. The default behavior of a container is to “Include” the attribute, event, or audience provided. You can set the rule to “Exclude” profiles that match the container criteria by changing the Include in the top-left corner of the tile to “Exclude.”  

In this example, the customer wants Family Flag = Yes, and then Season Ticket Holders from 2021 OR Single Game Ticket Buyers from 2021. It is not possible to mix ‘and’ with ‘or’ without a Simple Container, so this is a crucial piece of segment building. So, by adding a Simple Container, we can then add the two Attributes and use an OR statement.  

frederick_richard_2-1656525096940.png

Note: This behaves like braces in Algebra to group logic. 

A child container can also be extracted and added inline to the parent container by selecting “unwrap container” on the child container. Select the ellipses (…) in the top-right corner of the child container to access this option. This can, however, change the logic of the segment. Use caution when doing this, and make sure it is in-line with the end logic you are looking for.  

Variable Containers

Now, let’s take it up a notch and talk Variable Containers. A Variable Container is created when dealing with an XDM Attribute or XDM Experience Event that lives anywhere inside an array. That means that there are multiple values for that field. It is saying “find me one such item in the array such that on that single item, these conditions hold.”  

Note: You do not have the option to ‘create a Variable Container’ like you would a Simple Container. Rather, this is done automatically by the fields being dragged onto the canvas if they are part of the same array. Dropping a second field in the array, inside the same variable container, creates different rules than dropping it outside the container.  

Here is an example of when/how to use Variable Containers for XDM Attributes: A customer wants to build a segment, looking for Newsletter subscribers who are currently opted-in. In the screenshot below, you will see two XDM attributes added to the same variable in the segment builder canvas. You can verify it is only one variable by looking at the variable listed on the left toolbar, under Browse Variables, and verifying that the rules visually exist in the same variable container (you can see the little ‘pill’ with the variable name in the header of the container).  

frederick_richard_3-1656525096943.png

So, why are we using a Variable Container in this circumstance versus using a Simple Container? The answer lies within the business requirements. For this segment, we want to ensure that people are subscribed to the Newsletter specifically. If we did not include the two attributes in the same variable, the Boolean (True/False) subscription flag attribute would look for ANY subscription that is marked as ‘True;’ rather than a specific Newsletter.  

Real World Example: Here is the JSON attribute view from a qualified user, which shows the Newsletter Subscription attribute, as well as the Boolean (True/False) subscription flag attribute on the same object within an array.  

 [{ 
            "email_list": "Newsletter", 
            "latest_opt_in_date": "2016-03-07T00:00:00Z", 
            "subscribed": true 
          },
]
 

By having both fields in the same container we include the above Profile while excluding the Profile below (because “newsletter” and “true” and in two different elements within the array): 

[{ 
            "email_list": "Newsletter", 
            "latest_opt_in_date": "2016-03-07T00:00:00Z", 
            "subscribed": false 
          }, 

{ 
            "email_list": "Product Updates", 
            "latest_opt_in_date": "2016-03-07T00:00:00Z", 
            "subscribed": true 
          },
]
 

Best Practices for Simple and Variable Containers 

You are wondering to yourself: When should I use a Simple Container and when should I use a Variable Container? It depends on your segment, and how the data is structured in the datasets. If you are looking to simply add a collection of nested rules, using AND/OR logic, a Simple Container makes the most sense.  

If you have an array, then your choice is if you want to ensure the rules are evaluated against the same element in the array (put the two fields in the same variable container) or not (use two different containers). 

Segment Example 

Real World Example: A customer needed a segment that was looking for customers who had purchased over a certain number of tickets, each year, and spent over a certain amount of money on those tickets. Initially, the thought was to simply add these various attributes as AND statements on the segment builder canvas. However, upon closer examination, we realized that each of these attributes existed on an object within the ticket history array; broken out by year. This required a Variable Container to ensure each year, which had its own object within an array, qualified for the other attributes included.  

frederick_richard_4-1656525096946.png

By grouping these attributes into Variable containers, we are grabbing the specific attributes from that specific season. Here is a look at a sample profile attribute that qualifies for this segment, displaying the objects within the ticketing history array for 2018 and 2019:   

[ { 
            "games_purchased_pri": 24, 
            "avg_price": 65.69, 
            "tickets_purchased_pri": 51, 
            "total_games_purchased": 24, 
            "total_spend": 3350, 
            "avg_order_value": 56.78, 
            "games_purchased_sh": 0, 
            "season": 2019, 
            "spend_pri": 3350, 
            "tickets_purchased_sh": 0 
          }, 
          { 
            "games_purchased_pri": 22, 
            "avg_price": 64.56, 
            "tickets_purchased_pri": 48, 
            "total_games_purchased": 22, 
            "total_spend": 3292.64, 
            "avg_order_value": 52.26, 
            "games_purchased_sh": 1, 
            "season": 2018, 
            "spend_pri": 3224, 
            "tickets_purchased_sh": 3 
          }, 
] 

What happens if the above segment does not add the attributes to a single variable container?

The segment would then look for the attributes within the profile but wouldn’t specifically group them by the objects where each year is located. For example, if we split the attributes away from the variable containers (screenshot below), it would then look for 2018 on any object within the ticketing history array, total games purchased and total ticketing dollars spent on any object (in this case, 2019). The object for the year 2018 doesn’t technically qualify for the other attributes used, such as games purchased 2+ and total ticketing spend $150+:  

frederick_richard_5-1656525096950.pngThe result is the below profile qualifies for the segment, when maybe it shouldn’t.  Why? Because by putting each field of the object array we have changed the segment logic such that each field criteria is evaluated independently and thus does not have to occur on the same element of the array. 

[{ 
            "games_purchased_pri": 4, 
            "avg_price": 39.15, 
            "tickets_purchased_pri": 13, 
            "total_games_purchased": 4, 
            "total_spend": 509, 
            "avg_order_value": 33.93, 
            "games_purchased_sh": 0, 
            "season": 2019, 
            "spend_pri": 509, 
            "tickets_purchased_sh": 0 
          }, 
          { 
            "games_purchased_pri": 22, 
            "avg_price": 64.56, 
            "tickets_purchased_pri": 48, 
            "total_games_purchased": 1, 
            "total_spend": 122, 
            "avg_order_value": 52.26, 
            "games_purchased_sh": 1, 
            "season": 2018, 
            "spend_pri": 3224, 
            "tickets_purchased_sh": 3 
          },
] 

Another use of variable containers: 

Having two events reference each other dynamically. You can read more about it here, click on the link below.  

frederick_richard_6-1656525096954.png

Using Variable Containers to Filter on Last Event: How to Capture Latest Experience Event in Adobe Experience Platform and Learn Dynamic Segmentation a... 

1 Comment