1. Manage headless experiences

Request and render a headless experience

Important

Feature availability is part of a phased rollout. Your organization may not see this functionality yet. It will become available when your environment is included in the rollout.

When your application runs a headless experience, it sends visitor and request information to SitecoreAI. SitecoreAI evaluates the request and returns the configured response for the personalization or assigned A/B/n test variant.

Your application uses the returned values to render the experience.

Request the experience

A request can include the following context:

FieldPurpose
clientKeyIdentifies your tenant
channelIdentifies the channel making the request
browserIdIdentifies an anonymous visitor
identifiersIdentifies a signed-in visitor
languageIdentifies the visitor's language
currencyCodeProvides the relevant currency
pointOfSaleIdentifies the site or property
uriIdentifies the current page or screen
paramsProvides additional context for the response

For signed-in visitors, use identifiers rather than relying only on browserId.

The information you provide depends on the integration method. For example, an SDK can reuse visitor or site information that was provided during initialization.

Render the response

SitecoreAI returns the configured API response for the personalization or assigned A/B/n test variant.

Use the returned values to render the experience in your application.

For example:

const decision = await fetchExperience();

if (!decision) {
  return <DefaultWelcome />;
}

return (
  <Welcome
    message={decision.message}
    discount={decision.discount}
    features={decision.features}
  />
);

Your application controls how and where the experience is displayed.

Handle an empty response

If SitecoreAI returns no response, for example because the visitor does not qualify or the service is unavailable, display your application's default content.

For applications with intermittent connectivity, request the experience while connectivity is available and store the response locally as appropriate. Responses are not cached on the device automatically.

Next step

To implement the request, run the headless experience using the integration method that matches your application.

If you have suggestions for improving this article, let us know!