Tell the SDK which CMS page to render. It fetches it from Contentful or Contentstack and swaps the entries a journey personalizes, at any depth.
A marketer personalizes a CMS page with a Personalization Trigger (the page's content key) and one or more Personalization Response steps that swap sections of the page. Your site asks the SDK for the page, and the SDK returns it with those sections already swapped, however deeply they are nested.
This page covers journeys whose Personalization Trigger has Server-side pull channel only switched off. With it on, the same page is served from your proxy: see Edge personalization.
import { contentfulAdapter } from "@xenia-martech/sdk-js/cms/contentful";
const cms = contentfulAdapter({ space, accessToken, include: 6 });
const { content } = await xenia.personalizePage({ contentType: "page", fields: { slug } }, {
cms,
contentKey: "home-main", // the page's Personalization Trigger content key
timeoutMs: 250,
});
// or by entry id: xenia.personalizePage("1Tl24n6FueOegEOALask0F", { cms, contentKey })content is the page entry, or null when it doesn't exist or the CMS fetch
failed. Already fetching the page yourself? Pass it in with
xenia.personalizeContent(page, { cms, contentKey }). On Contentstack, fetch it
with include_all=true so references come back as entries.
contentKey is required. It scopes the page to that one journey, so no other
journey is consulted about its sections.
timeoutMs budget (default 300 ms),
capped by maxRounds (default 3). It never throws: anything undecided keeps its
base content.pendingTargets(page, cms) lists the entries Xenia still has to decide, read from
the markers with no network call. Render those as skeletons and the visitor never
sees base content that is about to change. The hooks' status(id) and
useXeniaEntry(id) report "pending" from the very first render.
Implement CmsAdapter for any other CMS. You write entryId, marker,
staticVariants, getField / setField, and fetchEntries / queryEntries.
The walk, the rounds, the budget and the splicing are shared.
Content Cloud pages are personalized through resolve(),
whose swaps name each section by its identifier. applyIdentifierSwaps replaces
every swapped reference at any depth:
const { personalized, swaps } = await xenia.resolve(productId, { data });
const entry = await applyIdentifierSwaps(base, personalized ? swaps : [], (id) => fetchEntry(id, 3));Each replacement loads once, a failed load keeps the base, and the input is never changed.