Run Sitecore Personalize personalizations
Using the Cloud SDK, you can personalize content for your site visitors by, for example, running interactive full stack experiences that are live in Sitecore Personalize. To run this type of experience in your JSS Next.js app, you use the personalize package of the Cloud SDK. Running the experience will return an API response, which contains the personalized content.
This walkthrough describes how to:
-
Install and initialize
@sitecore-cloudsdk/personalize/browser. -
Find the friendly ID in Sitecore Personalize.
-
Run the experience on your site.
-
Verify that the experience is running.
-
Have a live interactive full stack experience in Sitecore Personalize to work with.
-
Make sure you're prepared for development with the Cloud SDK.
-
In your code editor, open the rendering app root folder
sxastarter.
Install and initialize @sitecore-cloudsdk/personalize/browser
The first step to running personalization is to install the @sitecore-cloudsdk/personalize package and initialize its browser module in your app.
To install the package and initialize the module:
-
In your code editor, in the
sxastarterfolder, open the terminal and install thepersonalizepackage by running the following command: -
In
src/pages/[[...path]].tsx, import the initializer function of thebrowsermodule:src/pages/[[...path]].tsxis a catch-all route. The code you add to it will run on all the webpages of your app. -
Inside the
SitecorePageconstant, directly before thereturnstatement, paste the following code, then save your changes:Replace the placeholder values with environment variable values from your SitecoreAI instance.
This code initializes the module using your context ID and site name, and it sets cookies on the browser side.
Find the friendly ID in Sitecore Personalize
After initializing the module, you need to find the friendly ID of the live interactive full stack experience you want to run on your site.
To find the friendly ID:
-
In Sitecore Personalize, click Experiences > Full stack, then the live interactive experience you want to run.
-
On the page of the experience, click Summary. The friendly ID is on the Details pane.

-
Copy the friendly ID. You'll use it in the next procedure to run the experience.
Run the experience on your site
After finding the friendly ID of the experience, you return to your code editor and run the experience on your site.
To run the experience:
-
In your code editor, in
src/pages/[[...path]].tsx, update the import statement for thepersonalize/browsermodule by importing thepersonalizefunction: -
Inside the
initPersonalizefunction, directly after theconsole.log()statement, paste the following code:Replace the placeholder value with the friendly ID of your experience.
This code runs the experience and logs its API response to the console.
-
Save your changes.
Verify that the experience is running
After updating your code, it's a good idea to check that the experience is running on your site.
To verify that the experience is running:
-
Start your rendering app by entering the following command in your terminal:
-
In your web browser, navigate to your JSS Next.js app, typically at
http://localhost:3000. -
In your web browser's developer tools, on the Console tab, verify that you see the following logs in the console:
The second log contains the response that was created for this experience in Sitecore Personalize.
-
In the developer tools, on the Network tab, in the Filter field, paste the following URL: https://edge-platform.sitecorecloud.io/personalize.
This lists the network requests related to running your experience.
-
In the list of requests, click a
POSTrequest that has the status of200 OK.A pane of request details displays.
-
In the request details pane, click the Response tab for the request.
The API response displays. This is the response that was created for this experience in Sitecore Personalize.
Next steps
You've now successfully run the experience on your site and received the API response for the experience in your app. You can now proceed to work with the response, for example, by displaying its content on your site.
Next, you can:
-
Learn more about running personalization in your JSS Next.js app.
-
Explore the reference documentation for the
personalizepackage. -
Implement other Cloud SDK functionality, such as data collection by capturing custom events.