EngageServer.personalize(personalizationData, callback[, timeout])
This is a server-side function used for implementing server-side tracking. If you want to implement client-side tracking instead, use the client-side functions.
The personalize()
function runs an interactive full stack experience or an interactive full stack experiment that's currently live in Sitecore Personalize. You must call this function with the friendlyId
of the live experience or experiment that you want to run.
Call this function to run a live Interactive full stack experience or a live Interactive full stack experiment only.
Web experiences and web experiments are run by the Engage SDK automatically.
You can find the friendlyId
in Sitecore Personalize, in a live interactive full stack experience or experiment, by clicking Summary. The friendlyId
is in Details > Friendly ID.
Here's an example of how to run an experience or experiment and log it to the console.
export async function middleware(req) {
const res = NextResponse.next();
// Load Engage API
const engageSettings = {
clientKey: "<client_key_PLACEHOLDER>",
targetURL: "<stream_api_target_endpoint_PLACEHOLDER>",
pointOfSale: "<point_of_sale_PLACEHOLDER>"
};
// Personalization data
const personalizationData = {
channel: "WEB",
currency: "EUR",
friendlyId: "running_shoes_popup_02",
// optional attributes:
params: { key: "value" }
}
const engageServer = await initServer(engageSettings);
await engageServer.personalize(personalizationData, (res) => {console.log(res)}, 4000);
return res;
};