Context
Use Context steps to create or update a set of variables that represent the context of a user (or insights into that user’s behavior) as they move through a Canvas. Each context variable includes a name, data type, and a value that can include Liquid. By setting context as part of your user journey, you can do things like delay messages or filter users based on context variables.
Context steps are currently in early access. Contact your Braze account manager if you’re interested in participating in this early access.
How it works
Each Context step is composed of a variable name and associated data type, or context variables (previously referred to as Canvas entry properties). These variables will follow a user through a Canvas and can be be accessed using the Liquid context
.
There are two ways to set context variables:
- At Canvas entry: Variables of events or API calls that trigger a user’s entry into a Canvas are stored as context variable.
- Using a Context step: You can create or update context variables in the step editor.
Creating a Context step
To create a Context step, add a step to your Canvas. Then, drag and drop the component from the sidebar, or select the plus button at the bottom of a step and select Context.
Defining context variables
- Give your Context variable a name.
- Select a data type.
- Enter a Liquid expression or select the Add Personalization button. This generates a Liquid snippet to use in your Liquid expression.
- Select Preview to view the context variable.
- Select Done to save the step.
You can use Context variables anywhere you can use Liquid, such as in Message and User Update steps, with the Add Personalization button.
Context variable types
Canvas Context variables that are created or updated in the step can be assigned types. Note that if the Liquid expression at runtime returns a value that doesn’t match the type, the context variable won’t be updated.
For example, if the context variable data type is set to Date but the value isn’t a date, then the variable won’t be updated. This means the following will occur:
- The user will either advance to the next step or exit the Canvas if it’s the last step in the Canvas.
- In your Canvas step analytics, this will be counted as Not Updated.
Braze will exit a user at the step if:
- The context variable doesn’t return any value.
- A call to an embedded Connected Content fails.
- The context variable types don’t match.
JSON types and Connected Content responses
Braze evaluates context variables that are expected to be JSON (or Object)-type from Connected Content responses into strings. To prevent context variables from being evaluated as strings, enter these results into this Liquid filter: as_json_string
. An example is:
1
2
{% connected_content http://example.com :save product %}
{{ product | as_json_string }}
Using context variables with Delay steps
You can add personalized delay options with the information from the Context step, meaning you can select the variable that delays users.