Customizing Personalization
Introduction
Personalization refers to offering different pricing, promotions or content based on the shopper’s attributes, known as traits. For example, an item’s price may only be discounted for shoppers who are over sixty five years old. Personalized pricing is also referred to as Dynamic Pricing or Differential Pricing.
How Cortex Process Traits
Cortex uses Subjects to manage its users. When a user logs in with an access token, a Subject is created and exists for the duration of the request. Personalization traits are modelled as attributes on the Subject and are called SubjectAttributes. If you have access to the Subject, then you also have access to the user’s traits.
Subject Lifecycle
The Subject is created by the HeaderToSubjectLifecycleFilter which assembles the Subject from HTTP inputs including the role, scope, and the user’s identity details. Additionally, traits sent through the x-ep-user-traits HTTP header and adds them to the subject’s attributes. Subject attributes are automatically added to the Commerce Engine Selling Context and can influence pricing, promotions, and dynamic content delivery.
Cortex internally infers traits using HTTP Request Tag Set Populator extensions that contribute additional SubjectAttributes to the Subject. As with the x-ep-user-traits HTTP header, the SubjectAttributes are automatically added to the Commerce Engine Selling Context and can influence pricing, promotions and dynamic content delivery.
Default supported subject attribute populators
The following subject attributes are supported out of the box:
| Subject Attribute Key | Populator Class | Priority |
|---|---|---|
DATA_POLICY_SEGMENTS | com.elasticpath.xpf.extensions.DataPolicyPopulator | 1000 |
AUTHORIZATION | com.elasticpath.xpf.extensions.AccessTokenTagSetPopulator | 1010 |
CURRENCY | com.elasticpath.xpf.extensions.CurrencyTagSetPopulator | 1010 |
LOCALE | com.elasticpath.xpf.extensions.LocaleTagSetPopulator | 1020 |
User traits (any key/value pairs specified in the x-ep-user-traits header) | com.elasticpath.xpf.extensions.UserTraitsTagSetPopulator | 1900 |
Configuring subject attribute populator precedence
With multiple HTTP Request Tag Set Populator extensions registered with Extension Point Framwork, attributes can potentially overlap. Therefore, lookups are evaluated in specific order to ensure the results returned for each request are consistent.
Each extension is assigned a priority using the @XPFAssignment priority attribute. Extensions are evaluated in order, from lowest priority value (i.e. 1) to highest (i.e. 2000).
How to configure the traits header size
Your Cortex application may require large amounts of personalization information in the traits header and the default header size (8K) may not be large enough. To increase header size, use the configurations provided by your web server. Changes are not required in Cortex to handle larger headers.