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 Processes 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.
The Subject is created by the SubjectLifecycleFilter which assembles the Subject from HTTP inputs including the role, scope, and the user's identity details. This filter takes the 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 SubjectAttributeLookups 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.
The image below describes an overview of the Subject's lifecycle.
How to turn the traits header on and off
You can disable the subject attributes traits header at deploy time or runtime by undeploying or removing the ep-rs-authentication-header-epcommerce bundle. The SubjectAttributeLookupStrategy responsible for processing the traits header is dynamically loaded at runtime, or never loaded if it is removed from the deployment package (WAR). Once this bundle is disabled, the traits header is ignored and doesn't affect Cortex resource requests.
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.