1. Personalization

SitecoreAI personalization and A/B/n testing

Version:

SitecoreAI page-level personalizations and A/B/n tests 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 runs these personalizations, and the Cloud SDK enables the personalization process in the following ways:

  • The Cloud SDK stores the sc_cid_personalize cookie in the web browser. This cookie is required for A/B/n tests to run.

  • The Personalize Middleware runs the personalize function of the server module of the Cloud SDK personalize package.

    When the function runs, the Cloud SDK sends a payload to Sitecore. The payload contains a list of page variant IDs 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. For example, you can exclude routes from personalization or disable personalization altogether.

Note

Certain SitecoreAI personalizations run at the edge.

Example payloads

Here's some Cloud SDK debug logs 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:

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:

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
If you have suggestions for improving this article, let us know!