Set Up Dynamic Context Variables
Use dynamic context variables to send user-defined attributes to the Personalization service with every personalization request. These attributes help refine recommendation responses and enable advanced filtering logic in your recommenders. By using dynamic variables, you can reduce the number of recommenders needed to deliver your use cases. You can define context variables in the Interactions SDK sitemap globally or for specific page types.
A dynamic context variable contains two fields: a name and a value.
| Field Name | Type | Required | Description |
|---|---|---|---|
name | String | Yes | The name of the contextual attribute. For example, color. |
value | String, Function, or Promise | Yes | The value of the contextual attribute. This can be a static string, a function that returns a string, or a promise that resolves to a string. For example, if the name is color, the value could be blue. |
You can define dynamic context variables in the Interactions SDK Sitemap globally using the global configuration. Alternatively, you can define them for specific page types using the pageTypes configuration.
For more information on how to use these contextual attributes for advanced filtering, see Filter Recommendations Using Dynamic Context Variables.