Personalize a page using affinities
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.
Affinities help you tailor experiences based on visitor interests. As a visitor views pages on your site, SitecoreAI calculates affinity scores that reflect which topics, categories, or attributes they view most. These scores are updated in near real time, and even during the same browser session, SitecoreAI can use the latest scores to show personalized page variants based on the visitor’s current behavior. Affinity scores from previous sessions are also taken into account, so personalization reflects both recent and ongoing interests.
SitecoreAI provides two ways to personalize and create page variants using affinities:
-
Use the out-of-box affinities condition - to personalize a page based only on affinity scores, without creating custom logic.
-
Create a custom condition - to apply more advanced logic, such as combining affinities with additional visitor data.
Both approaches result in the same outcome: a personalized page variant that adapts automatically to each visitor.
Make sure that you have already set up affinities for your site and assigned field names and values (key-value pairs) for the pages you want to personalize.
Use the out-of-box affinities condition
Use this procedure when you want to personalize a page based only on the affinity scores.
To personalize a page using the out-of-box affinities condition:
-
In the Page builder in Editor mode, in the site tree, click the page you want to create a variant for.
-
On the Personalize tab, in the left-hand side panel, click Create variant.
-
To create the audience intended for that page variant, in the Create new page variant dialog, enter the page variant name and click Next.
-
In the Create your audience dialog, in Build mode, enter the name of your audience and click Add first condition.
-
In the search field in the Conditions right-hand pane, search for Top Affinity.
The Top Affinity condition targets visitors whose selected affinity field value is the highest score in their profile.

-
Click
to add the condition. -
In the audience builder, complete the condition using the following fields:
-
affinity name - enter the field value assigned to the page being personalized.
For example, for the field category, possible values might be shoes, clothes, bags.
You can enter multiple values if needed. Press Enter after each value.
-
affinity group (optional) - enter the field name assigned to the page being personalized.
For example, default fields like category, brand, or any custom field you defined.
ImportantField names and values must match exactly the names and values assigned to the page during affinities setup. Any mismatch will prevent the condition from working correctly.
-
-
Optionally, if needed, you can also:
-
Add additional conditions and logical operators between them.
-
Reorder conditions or groups using the up
or down
arrows.
-
-
Click Save and close to save the audience.
-
Your new page variant is now available in the list of variants in the left pane. You can now edit the variant. When editing is complete, publish the variant.
SitecoreAI will then automatically show the variant to visitors whose highest affinity score matches the selected field value or values.
Create a custom condition that includes affinities
Use this procedure when you need to combine affinity scores with additional visitor data or business rules.
To personalize a page using a custom condition that includes affinities:
-
In the Page builder in Editor mode, in the site tree, click the page you want to create a variant for.
-
On the Personalize tab, in the left-hand side panel, click Create variant.
-
To create the audience intended for that page variant, in the Create new page variant dialog, enter the page variant name and click Next.
-
In the Create your audience dialog, in Build mode, enter the name of your audience and click Add first condition.
-
In the Conditions right-hand panel, click Custom, then click Create.

-
Enter a name for the new condition.
-
In the code editor, choose one of the following options:
-
Manually create the custom condition using JavaScript, if you are familiar with coding.
-
Use the Code Assistant to describe the logic you want to create in plain language.
For example, you can prompt the Code Assistant with:
Write a condition to display event-specific agendas when affinity score for topic = AI is greater than 50% and the visitor has viewed the AI Summit 2026 registration page
The following sample JavaScript shows how affinity scores can be combined with another condition:
-
-
Click Save to apply your changes. After saving your custom condition, make sure to define the condition output using the appropriate parameter names.
-
Your new page variant is now available in the list of variants in the left pane.
You can now edit the variant. When you are done editing, you must publish it for it to be visible to the audience you defined. This means when a visitor’s affinity score is highest for the selected field value(s), SitecoreAI automatically shows the personalized page variant.