This topic provides instructions for how to build formula expressions for Advanced Decision and Activity steps.
You can use formula expressions to test whether a statement is true or false when a consumers reaches an Advanced Decision or Activity step in a journey. For Advanced Decision steps, the answer will be used to decide which of the two outbound paths the consumer will take. For Activity steps, the answer is used to determine whether the consumer progresses to this Activity step. If applied to the starting Activity step, the answer is used to determine if the consumer gets added to the journey.
Formula expressions can evaluate data about the current consumer, the activities that added them to the journey or updated their position within it, or the current journey instance.
You can construct a formula expression from a combination of operators and data attributes. In a formula expression, you will use operators to define the relationship between data attributes and, in some advanced use cases, you may also use functions.
Operators connect two or more data attributes to construct a logical expression. The Advanced Formula Expression field supports three types of operators: Arithmetic, Relational and Logical. Please review the Getting Started section below to find out more about these and how to use them to build your formula expression.
Member Attributes (also referred to as "People Attributes") are fields stored within an EDP Member Profile. They record a consumer's traits and preferences as well as additional information related to a consumer, such as their last purchase date or lifetime value.
To review the complete list of all available Member Attributes:
From the EDP navigation menu, select Definitions > People Attributes.
Browse through the available Member (People) Attributes, or search for specific ones using the search box at the top right of the page.
Use the "internal name" in formula expressions. For example:
user.profile['address_isvalid']
To find out more about Member (People) Attributes please see the EDP Online Help.
You can use details from EDP Activities that your journey tracks, so long as they occur prior to the Advanced Decision or Activity step. For example, in an Abandoned Cart journey, you might want to determine if the consumer's cart value was greater than $100.
The Activity Attributes available depend on the Activity Type (for example, Abandoned Cart, Purchase, or Sign Up). Each Activity Type comprises a series of common Attributes as well as custom ones that track specific details unique to that Activity, such as the cart value of an Abandoned Cart. To review a complete list of available Activity Attributes:
From the EDP navigation menu, select Definitions > Activity Types.
Browse through the available Activity Types, or search for specific ones using the search box at the top right of the page.
For your chosen Activity Type, click on its name to view a list of Activity Attributes.
Use the Activity’s "internal name" and the Activity Attribute’s "internal name" in formula expressions. For example:
activity['sl_abandoned_cart']['cart_value']
To find out more about Activity Types and their attributes please see the EDP Online Help.
Journey Attributes relate to the journey instance for the current consumer. Currently, the platform supports the "Journey Start Date" attribute, that can be referenced as follows:
journeyStart
In this section, you can review examples of the kinds of expressions that can be constructed using data attributes and operators to suit your business needs.
Let’s assume we want an Advanced Decision step to decide the journey path based on the age and the gender of the consumer passing through this journey. One of the decision paths will target all males over 18, and the other path will target everyone else. We will construct the formula expression using the Member Attributes "Age" and "Gender" as follows:
user.profile['age']
user.profile['gender']
We will then use relational operators to set the required conditions for our decision:
user.profile['gender'] == 'male'
user.profile['age'] > 18
Finally, we will combine the two expressions above using a logical operator as shown:
user.profile['gender'] == 'male' AND user.profile['age'] > 18
Let’s assume we want to use an Activity step to start a journey, but only consumers who made a purchase of at least $500 should get added to the journey. We will construct the formula expression by using the Purchase activity attribute "Purchase Value" as follows:
activity['sl_purchase']['purchase_value']
We will then use relational operators to set the required conditions for our decision:
activity['sl_purchase']['purchase_value'] >= 500
The following arithmetic operators allow for math to be performed on numeric Attributes.
Op |
Description |
Usage Example |
+ |
Performs addition |
If you want to calculate an increased discount: activity['sl_abandoned_cart']['sl_overall_discount'] + 10 |
- |
Performs subtraction |
If you want to calculate a reduction in the value of the consumer's cart: activity['sl_abandoned_cart']['cart_value'] - 100 |
* |
Performs multiplication |
If you want to calculate double the discount: activity['sl_abandoned_cart']['sl_overall_discount'] * 2 |
/ |
Performs division |
If you want to calculate half of the discount: activity['sl_abandoned_cart']['sl_overall_discount'] / 2 |
% |
Gets the remainder after a division |
Examples: 50%2 Result: 0 10%3 Result: 1 |
The following relational operators allow for comparisons to be made.
Op |
Description |
Usage Example |
< |
Less than |
If you want to see if the quantity of items in the cart is less than 10: activity['sl_abandoned_cart']['sl_item_count'] < 10 |
< |
Greater than |
If you want to see if the total value of the consumer's cart is more than $1000: activity['sl_abandoned_cart']['sl_total'] > 1000 |
== |
Equivalence |
If you want to see if the consumer is in UK: user.profile['mailing_country'] == 'UK' |
!= |
Not equal to |
If you want to confirm that your consumer's cart has chargeable items: activity['sl_abandoned_cart']['cart_value'] != 0 |
<= |
Less than or equal to |
If you want to check if your consumer's age is 18 or less: user.profile['age'] <= 18 |
>= |
Greater than or equal to |
If you want to check if your consumer's age is 18 or more: user.profile['age'] >= 18 |
The following logical operators allow expressions to be combined to give more complex decisions.
Op |
Description |
Usage Example |
AND |
Returns true if both conditions are true |
If you want to check if a consumer is male and over the age of 18: user.profile['age'] == 'male' AND user.profile['age'] > 18 |
OR |
Returns true if one of the conditions is true |
If you want to check if a consumer is either in the USA or Canada: user.profile['mailing_country'] == 'USA' OR user.profile['mailing_country'] == 'Canada' |
NOT |
Reverses the logical value associated with it |
If you want to check if your consumers are not in UK: NOT (user.profile['mailing_country'] == 'UK') |