Run a headless experience
After a headless personalization or A/B/n test is Live, your application can run it to receive the configured response for the personalization or assigned test varia
For details about what your application sends, what SitecoreAI returns, and what to do if no response is returned, see Request and render a headless experience.
Use the Integration guide in SitecoreAI for instructions and code specific to the selected experience.
You can run a headless experience using Content SDK, REST API, or Cloud SDK.
Open the Integration guide
To open the Integration guide:
-
In the navigation menu, click Optimization.
-
In the left sidebar, click Tests & personalizations.
-
Select Headless.
-
Select the live headless experience you want to run.
The Configuration page opens.
-
In the right pane, click the Connect tab.
-
Click Open guide.
The Integration guide pane opens.
-
Select the integration method that matches your application:
The Integration guide provides the request or code specific to the selected experience. SitecoreAI returns the configured API response, which your application uses to render the experience.
Content SDK
Make sure:
Your application uses Content SDK 2.x and is initialized with the analytics, events, and personalize plugins. For details, see the Content SDK initialization guide.
To run the experience from a Content SDK application:
-
In the Integration guide pane, click the Content SDK tab.
-
In Step 1 - Run the personalization, click the copy icon to copy the TypeScript or JavaScript template, add it to your application, and run it.
The SDK reuses the visitor's client ID and site information from initialization, so you only need to provide the friendly ID of the headless experience.
For example:
REST API
Make sure:
- You have a Sitecore context ID for the environment. Include this ID in each request.
- You have an analytics identifier for the site to which traffic and goal results are attributed.
To run the experience using the REST API:
-
In the Integration guide pane, click the REST API tab.
-
In the Sitecore context ID field, enter the context ID for your environment.
If necessary, click View context IDs to find the ID.
-
In the Analytics identifier list, select the analytics identifier to use for tracking.
-
In Step 1 - Get a client ID, click the copy icon to copy the request template and send the request.
A client ID identifies the visitor across requests. For a new visitor, retrieve the
idfrom the response, store it, and reuse it as<CLIENT_ID>in subsequent requests for the same visitor.Send this request from the visitor's browser or device so Sitecore can derive location and device information from the request.
-
In Step 2 - Run the personalization, click the copy icon to copy the request template and send the personalization request.
Use the analytics identifier selected in step 3 and the client ID obtained in step 4.
Cloud SDK
Make sure:
Your application uses the Sitecore Cloud SDK and is initialized with the events and personalize packages by using addEvents() and addPersonalize(). For details, see the Cloud SDK initialization guide.
To run the experience from a Cloud SDK application:
-
In the Integration guide pane, click the Cloud SDK tab.
-
In Step 1 - Run the personalization, click the copy icon to copy the TypeScript or JavaScript template, add it to your application, and run it.
The SDK reuses the visitor's client ID and site information from initialization, so you only need to provide the friendly ID of the headless experience.
For example: