---
title: "SitecoreAI personalization and A/B/n testing"
slug: "sitecoreai-personalization-and-a-b-n-testing"
abstract: "Understand how SitecoreAI personalizations and A/B/n testing run automatically in Content SDK and JSS apps, and how the Cloud SDK enables the personalization process."
---
# SitecoreAI personalization and A/B/n testing

[SitecoreAI page-level personalizations](https://doc.sitecore.com/sai/en/users/sitecoreai/personalize.html) and [A/B/n tests](https://doc.sitecore.com/sai/en/users/sitecoreai/a-b-n-testing.html) are typically created by marketers, and they run automatically in Content SDK and JSS apps, with no coding required.

Behind the scenes, the [Personalize Middleware](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/page-personalization-and-component-a-b-n-testing.html) runs these personalizations, and the Cloud SDK enables the personalization process in the following ways:

- The Cloud SDK stores the `sc_{sitecoreEdgeContextId}_personalize` [cookie](https://doc.sitecore.com/sdk/en/developers/004/cloud-sdk/en/cloud-sdk-cookies.html) in the web browser. This cookie is required for A/B/n tests to run.
- The Personalize Middleware runs the [`personalize`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize/cloud-sdk-personalize-server/functions/cloud-sdk-personalize-server-personalize.html "personalize") function of the `server` module of the Cloud SDK [`personalize`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize.html "@sitecore-cloudsdk/personalize") package.

    When the function runs, the Cloud SDK sends a payload to Sitecore. The payload contains [a list of page variant IDs](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize/cloud-sdk-personalize-browser/interfaces/cloud-sdk-personalize-personalizedata.html "PersonalizeData") and other personalization data. Then, if a matching page variant ID is found, it is returned in the response. The Personalize Middleware then uses that page variant ID to display the personalized page variant to the site visitor.

Although SitecoreAI personalizations automatically run with no coding required, you can [manually configure them](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/configure-personalization-in-a-next-js-jss-app.html#UUID-030fa80e-067f-9052-8bb8-6d6e46daba49_section-idm1403329768567788). For example, you can exclude routes from personalization or disable personalization altogether.

> [!note]
> Certain SitecoreAI personalizations run [at the edge](https://doc.sitecore.com/xmc/en/users/xm-cloud/en/specifying-variables-for-conditions.html).

## Example payloads

Here's some Cloud SDK [debug logs](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/getting-started/prerequisites.html "Prerequisites") showing examples of the payload the Cloud SDK sends to Sitecore, together with the example response returned.

The following is a payload that contains a list of two page variant IDs. A matching page variant ID is found and returned in the response:

```bash
sitecore-cloudsdk:personalize Personalize request:

https://<...>.sitecorecloud.io/v1/personalize?sitecoreContextId=<...>&siteId=<...> with options: {
  body: '{"channel":"WEB","clientKey":"","currencyCode":"USD","friendlyId":"<...>","guestRef":"<...>","language":"en","params":{"referrer":"about:client","utm":{}},"pointOfSale":"","variants":["614149d5c8a344fa9918868a30a0e364","3f027aa93fe045109e4bb57b62c7b5cd"],"browserId":"<...>"}',
  headers: {
  Content-Type: 'application/json',
  X-Library-Version: '0.3.1',
  x-sc-correlation-id: '18b54e92b5c841369c507f58440f5396',
  User-Agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'
},
  method: 'POST'
} +0ms

sitecore-cloudsdk:personalize Personalize response in 218ms : {
  headers: {
  access-control-allow-origin: '*',
  alt-svc: 'h3=":443"; ma=86400',
  cf-ray: '8dd364061ac3dc80-FRA',
  connection: 'keep-alive',
  content-encoding: 'gzip',
  content-type: 'application/json; charset=UTF-8',
  date: 'Mon, 04 Nov 2024 `08:56`:25 GMT',
  server: 'cloudflare',
  strict-transport-security: 'max-age=2592000; includeSubDomains; preload',
  transfer-encoding: 'chunked',
  vary: 'Accept-Encoding'
},
  redirected: false,
  status: 200,
  statusText: 'OK',
  url: 'https://<...>.sitecorecloud.io/v1/personalize?sitecoreContextId=<...>&siteId=<...>',
  body: { variantId: '3f027aa93fe045109e4bb57b62c7b5cd' }
} +0ms
```

The following is a payload that contains one page variant ID. No matching page variant ID is found, so the `"No matching variant"` message is returned in the response:

```bash
sitecore-cloudsdk:personalize Personalize request:

https://<...>.sitecorecloud.io/v1/personalize?sitecoreContextId=<...>&siteId=<...> with options:
{
  body: '{"channel":"WEB","clientKey":"","currencyCode":"USD","friendlyId":"<...>","guestRef":"<...>","language":"en","params":{"referrer":"about:client","utm":{}},"pointOfSale":"","variants":["61057f8637b54ee1916e7fdcc0f541cf"],"browserId":"<...>"}',
  headers: {
  Content-Type: 'application/json',
  X-Library-Version: '0.3.1',
  x-sc-correlation-id: '283d96b7800d4588aa0236feefaa8be9',
  User-Agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0'
},
  method: 'POST'
} +0ms

sitecore-cloudsdk:personalize Personalize response in 412ms:
{
  headers: {
  access-control-allow-origin: '*',
  alt-svc: 'h3=":443"; ma=86400',
  cf-ray: '8c173e9afacd0b54-AMS',
  connection: 'keep-alive',
  content-length: '33',
  content-type: 'application/json; charset=UTF-8',
  date: 'Wed, 11 Sep 2024 `11:16`:15 GMT',
  server: 'cloudflare',
  vary: 'Accept-Encoding'
},
  redirected: false,
  status: 200,
  statusText: 'OK',
  url: 'https://<...>.sitecorecloud.io/v1/personalize?sitecoreContextId=<...>&siteId=<...>',
  body: { message: 'No matching variant' }
} +0ms
```