The Shopper Context API is essential for managing personalized shopping experiences on your storefront. It is designed to optimize interactions for both guest and registered users by setting context-specific attributes that enhance personalization and efficiency.
When setting shopper context, the API utilizes the USID derived from the SLAS token, ensuring a seamless and secure integration.
important: - Always set shopper context information from your Backend for Frontend (BFF) using private clients. Do not use public clients for this purpose.
- Include the
siteIdquery parameter in all Shopper Context API requests (GET,PUT,PATCH, andDELETE).
When to Set Shopper Context
- Initial visit or login: Implement shopper context when a shopper logs in or initially visits the storefront, immediately after obtaining the SLAS (Shopper Login and Access Services) token.
- Token refresh: For SLAS token refresh, reuse the existing
USIDto maintain continuity and prevent duplicate records. This is important due to the resources available to store shopper context data. - Shopper login transition: Set shopper context when:
- A guest shopper subsequently logs in as a registered shopper.
- A registered shopper subsequently logs in as a guest shopper.
- Session Management: Reset the context upon user login as logging out clears the existing shopper context.
Shopper Context Updates
- Context lifetime: Shopper context records last 1 day for guest shoppers and 7 days for registered shoppers. Regular updates are crucial to keep the context current.
- Quota limits: Be aware of the default quota limits for the number of shopper context records that can be created in a B2C Commerce instance:
- 5000 records for non-Production instances.
- 5 million for Production instances.
- If you have a legitimate need to increase the limit in your Production instances, contact your Customer Success Manager or Account Executive.
- Some steps to take before reaching out to increase the quota limits:
- Lower the Time-to-live (TTL) for registered shopper context from 7 days to 1 or 2 days to automatically clear out context information. Context information can be reset when the shopper logs in again.
- Reuse the
USIDfor the same shopper to avoid duplicate shopper context records. - Explicitly log out shoppers to delete the corresponding shopper context record.
- In B2C Commerce version 25.1, view your quota and usage. Log in to Business Manager and navigate to Administration > Site Development > Salesforce Commerce API Settings.
- Avoid duplicates: Reuse
USIDs and verify existing contexts before setting new ones. - Efficient resource use: Regularly update existing contexts to optimize the limited storage available.
- Preferred timing for updates: Align context updates with token refresh events to maintain consistency and minimize redundant updates.
Integration
- Update your API integrations to include the
siteIdquery parameter in all requests to the Shopper Context API. The following example shows the updated request format:
shopper/shopper-context/v1/organizations/{organizationId}/shopper-context/{usid}?siteId={siteId}
When Not to Use Shopper Context
Do not use Shopper Context when attributes like customer profiles and addresses are automatically assigned and evaluated.
Shopper Context Use Cases
- Store personalization: At login, use the Shopper Context API to set the store ID in both the
customerQualifierandassignmentqualifier, ensuring tailored interactions per store. - Dynamic personalization: Use store IDs from the Shopper Context for personalized pricing and promotions during the session.
- The store ID is retrieved from the context and stored in the session for future reference, for example:
session.custom.storeId. - If dynamic customer groups are set for specific store IDs, it activates experiences assigned with the corresponding customer groups.
- The store ID is retrieved from the context and stored in the session for future reference, for example:
- Pricebook and promotion triggers: Use shopper context to activate specific pricebooks and promotions. For example, setting the store ID to
BOST1might trigger theBOSPRICEBOOKand10%OFFPROMOTIONfor that particular store. Subsequent product retrieval calls will return personalized responses based on these triggers.
Constraints
Sorting Rules are not supported.