Personalization Functions
The Personalization drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.
| Function | Description |
|---|---|
fetchPersonalizationData | Request the customer group, applied segments, and cart rules from Adobe Commerce based on the cart ID.. |
getPersonalizationData | Retrieves the saved personalization data from a cookie.. |
getStoreConfig | Returns information about the store configuration related to personalization.. |
savePersonalizationData | Saves the personalization data to a cookie for later retrieval.. |
fetchPersonalizationData
The fetchPersonalizationData can be used to request the customer group, applied segments, and cart rules from Adobe Commerce based on the cart ID.
const fetchPersonalizationData = async ( cartId: string): Promise<PersonalizationData | null>| Parameter | Type | Req? | Description |
|---|---|---|---|
cartId | string | Yes | The ID of the shopping cart. |
Events
Does not emit any drop-in events.
Returns
Returns PersonalizationData or null.
getPersonalizationData
The getPersonalizationData function retrieves the saved personalization data from a cookie.
const getPersonalizationData = async (): PersonalizationDataEvents
Does not emit any drop-in events.
Returns
Returns PersonalizationData.
getStoreConfig
The getStoreConfig function returns information about the store configuration related to personalization.
const getStoreConfig = async (): Promise<StoreConfigModel | null>Events
Does not emit any drop-in events.
Returns
Returns StoreConfigModel or null.
savePersonalizationData
The savePersonalizationData function saves the personalization data to a cookie for later retrieval.
const savePersonalizationData = async ( data: PersonalizationData): Promise<void>| Parameter | Type | Req? | Description |
|---|---|---|---|
data | PersonalizationData | Yes | Personalization data containing groups, segment, and cart price rules. |
Events
Emits the personalization/updated event.
Emits the personalization-updated event with the saved personalization data, including customer segments, groups, and cart rules.
Returns
Returns void.
Data Models
The following data models are used by functions in this drop-in.
PersonalizationData
The PersonalizationData object is returned by the following functions: fetchPersonalizationData, getPersonalizationData.
interface PersonalizationData { segments: string[], groups: string[], cartRules: string[]}StoreConfigModel
The StoreConfigModel object is returned by the following functions: getStoreConfig.
interface StoreConfigModel { shareActiveSegments: boolean; shareCustomerGroup: boolean; shareAppliedCartRule: boolean; customerAccessTokenLifetime: number;}