Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

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: 3.1.1
FunctionDescription
fetchPersonalizationDataRequest the customer groups, applied segments, and cart price 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.

The fetchPersonalizationData function can be used to request the customer groups, applied segments, and cart price 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.

Does not emit any drop-in events.

Returns PersonalizationData or null.

The getPersonalizationData function retrieves the saved personalization data from a cookie.

const getPersonalizationData = async (): PersonalizationData

Does not emit any drop-in events.

Returns PersonalizationData.

The getStoreConfig function returns information about the store configuration related to personalization.

const getStoreConfig = async (): Promise<StoreConfigModel | null>

Does not emit any drop-in events.

Returns StoreConfigModel or null.

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, segments, and cart price rules.

Emits the personalization/updated event.

Emits the personalization-updated event with the saved personalization data, including customer segments, groups, and cart price rules.

Returns void.

The following data models are used by functions in this drop-in.

The PersonalizationData object is returned by the following functions: fetchPersonalizationData, getPersonalizationData.

interface PersonalizationData {
segments: string[],
groups: string[],
cartRules: string[]
}

The StoreConfigModel object is returned by the following functions: getStoreConfig.

interface StoreConfigModel {
shareActiveSegments: boolean;
shareCustomerGroup: boolean;
shareAppliedCartRule: boolean;
customerAccessTokenLifetime: number;
}