uniform-esi-ssr configuration
This endpoint is used in implementations that use both Optimize and Deploy.
#
Context dataThe context
describes the state at the time the endpoint was
called. This includes things like who the user is, which site
was accessed and which language was used.
Uniform adds several properties to the context
by adding a
custom processor to the pipeline getLayoutServiceContext
.
These properties are needed in order for the Uniform tracker
to work properly.
The following properties are added:
personalization
testing
tracking
#
Route dataThe route
describes the combination of item, device and language
that was resolved along with the presentation details that describe
the placeholders and components associated with combination.
esi-context
#
Placeholder: Uniform adds a new placeholder to the route
order to accomodate
the Edge Context.
This placeholder contains components that represent the logic that
generates the Edge Context.
#
RenderingsEdge-side personalization involves generating conditional logic that determines the information included in Layout Service output. This conditional logic must be described using components. The front-end application converts these components into instructions for the CDN.
This process involves Uniform changing the components that Layout
Service includes in the route
output.
note
Uniform only changes components that have personalization rules defined on them. Components that are not personalized are not changed.
When a rendering has no personalization rules assigned to it, the rendering is represented by a component that maps directly to the rendering:
{ "uid": "338696f9-3b1c-42a0-bcc2-0b30a453ac4c", "componentName": "Hero", "dataSource": "{ORIGINAL DATASOURCE}", "fields": { "text": { "value": "You have expressed little interest in architecture. " }, "subtitle": { "value": "Architecture" }, "title": { "value": "About" } }}
However, when personalization rules are assigned to a rendering, Uniform creates a structure that represents the conditional logic of the personalization rules. The following is an example of the logic that is rendered:
The logic above can be expressed in JavaScript in the following way:
{ if (rule1) { return component1; } else if (rule2) { return component2; } else { return defaultComponent; }}
In order for this logic to be expressed in Layout Service output, a convention using placeholders and components is used:
- The top-level component uses the component type
EsiChoose
. - This component has a placeholder named
esi-choose
that contains an array of elements.- Each element in the array represents a personalization rule that a business user assigned to the rendering.
- Each personalization rule uses the component type
EsiWhen
. - Each personalization rule has a
test
parameter that represents the logic for the condition assigned to the rule. - Each personalization rule has a placeholder named
esi-when
that contains an array of elements.- There is only ever 1 element in the array.
- The element represents the personalized component.
- The default personalization rule uses the component type
EsiOtherwise
. - The default personalization rule has a placeholder named
esi-otherwise
that contains an array of elements.- There is only ever 1 element in the array.
- The element represents the default (unpersonalized) component.
The following is an example of the configuration described above:
{ "uid": "RENDERING UID", "componentName": "EsiChoose", "dataSource": null, "params": null, "fields": {}, "placeholders": { "esi-choose": [ { /* START: Personalization rule 1 */ "uid": "RENDERING UID", "componentName": "EsiWhen", "dataSource": null, "params": { /* Test is the expression of the condition logic */ "test": "$(ESI_CONTEXT_personalization_rules{'RENDERING UID'})=='RULE 1 ID'" }, "placeholders": { "esi-when": [ { /* Component used when the rule matches */ "uid": "RENDERING UID", "componentName": "RENDERING NAME", "dataSource": "PERSONALIZED DATASOURCE", "params": {}, "fields": {/* Datasource fields */}, "componentId": "RENDERING ID", "personalization": { "changes": { "component": null, "data": { "before": "ORIGINAL DATASOURCE", "after": "PERSONALIZED DATASOURCE" }, "hide": false }, "component": { "id": "RENDERING ITEM ID", "name": "RENDERING NAME" }, "page": { "id": "ITEM ID", "name": "ITEM NAME" }, "rule": { "id": "RULE 1 ID", "name": "RULE 1 NAME" }, "isIncludedInTest": false }, "itemId": "ITEM ID", "itemName": "ITEM NAME" } ] } /* END: Personalization rule 1 */ }, { /* START: Personalization rule 2 */ "uid": "RENDERING UID", "componentName": "EsiWhen", "dataSource": null, "params": { /* Test is the expression of the condition logic */ "test": "$(ESI_CONTEXT_personalization_rules{'RENDERING UID'})=='RULE 2 ID'" }, "placeholders": { "esi-when": [ { /* Component used when the rule matches */ "uid": "RENDERING UID", "componentName": "RENDERING NAME", "dataSource": "PERSONALIZED DATASOURCE", "params": {}, "fields": {/* Datasource fields */}, "componentId": "RENDERING ID", "personalization": { "changes": { "component": null, "data": { "before": "ORIGINAL DATASOURCE", "after": "PERSONALIZED DATASOURCE" }, "hide": false }, "component": { "id": "RENDERING ITEM ID", "name": "RENDERING NAME" }, "page": { "id": "ITEM ID", "name": "ITEM NAME" }, "rule": { "id": "RULE 2 ID", "name": "RULE 2 NAME" }, "isIncludedInTest": false }, "itemId": "ITEM ID", "itemName": "ITEM NAME" } ] } /* END: Personalization rule 2 */ }, { /* START: Default personalization rule */ "uid": "00000000-0000-0000-0000-000000000000", "componentName": "EsiOtherwise", "dataSource": null, "params": null, "placeholders": { "esi-otherwise": [ { "uid": "RENDERING UID", "componentName": "RENDERING NAME", "dataSource": "ORIGINAL DATASOURCE", "params": {}, "fields": {/* Datasource fields */}, "componentId": "RENDERING ID", "itemId": "ITEM ID", "itemName": "ITEM NAME" } ] } /* END: Default personalization rule */ } ] }}