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
Section titled “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
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns PersonalizationData or null.
getPersonalizationData
Section titled “getPersonalizationData”The getPersonalizationData function retrieves the saved personalization data from a cookie.
const getPersonalizationData = async (): PersonalizationDataEvents
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns PersonalizationData.
getStoreConfig
Section titled “getStoreConfig”The getStoreConfig function returns information about the store configuration related to personalization.
const getStoreConfig = async (): Promise<StoreConfigModel | null>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns StoreConfigModel or null.
savePersonalizationData
Section titled “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
Section titled “Events”Emits the personalization/updated event.
Emits the personalization-updated event with the saved personalization data, including customer segments, groups, and cart rules.
Returns
Section titled “Returns”Returns void.
Data Models
Section titled “Data Models”The following data models are used by functions in this drop-in.
PersonalizationData
Section titled “PersonalizationData”The PersonalizationData object is returned by the following functions: fetchPersonalizationData, getPersonalizationData.
interface PersonalizationData { segments: string[], groups: string[], cartRules: string[]}StoreConfigModel
Section titled “StoreConfigModel”The StoreConfigModel object is returned by the following functions: getStoreConfig.
interface StoreConfigModel { shareActiveSegments: boolean; shareCustomerGroup: boolean; shareAppliedCartRule: boolean; customerAccessTokenLifetime: number;}