Skip to main content
Users
CloudPortalLogin
  • Powered byPowered by
Developing with Sitecore Personalize
Data privacy
Before you start sending data
Integrating with Sitecore Personalize
Stream API
Personalize API Flow execution
REST APIs
  • Sitecore Personalize for developers
  • Stream API
  • Sitecore Engage SDK reference
  • Functions
  • EngageServer.personalize(personalizationData, callback[, timeout])

EngageServer.personalize(personalizationData, callback[, timeout])

Note

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.

Note

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.

sidebar. Parameters

Parameter

Type

Description

Note

personalizationData

object

Event and experiment data.

Specify the friendlyId in this object.

callback

function

This callback function handles the response.

N/A

[timeout]

optional

integer

Minimum 0

The number of milliseconds before the function times out and returns an error.

When you use timeout, use try-catch blocks to handle errors.

For example, set the value to 200 for the function to time out in 0.2 seconds.

Here's an example of how to run an experience or experiment and log it to the console.

RequestResponse
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;
};

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2025 Sitecore