Skip to content

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.

Version: 1.0.1
FunctionDescription
fetchPersonalizationDataRequest the customer group, applied segments, and cart rules from Adobe Commerce based on the cart ID..
getPersonalizationDataRetrieves the saved personalization data from a cookie..
getStoreConfigReturns information about the store configuration related to personalization..
savePersonalizationDataSaves 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>
ParameterTypeReq?Description
cartIdstringYesThe 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 (): PersonalizationData

Events

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>
ParameterTypeReq?Description
dataPersonalizationDataYesPersonalization 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;
}