1. Personalize

Personalize a page using affinities

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.

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:

Both approaches result in the same outcome: a personalized page variant that adapts automatically to each visitor.

Before you begin

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:

  1. In the Page builder in Editor mode, in the site tree, click the page you want to create a variant for.

  2. On the Personalize tab, in the left-hand side panel, click Create variant.

  3. To create the audience intended for that page variant, in the Create new page variant dialog, enter the page variant name and click Next.

  4. In the Create your audience dialog, in Build mode, enter the name of your audience and click Add first condition.

  5. 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.

    Screenshot of the audience builder with Top Affinity condition added.
  6. Click to add the condition.

  7. 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.

    Important

    Field 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.

  8. Optionally, if needed, you can also:

  9. Click Save and close to save the audience.

  10. 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:

  1. In the Page builder in Editor mode, in the site tree, click the page you want to create a variant for.

  2. On the Personalize tab, in the left-hand side panel, click Create variant.

  3. To create the audience intended for that page variant, in the Create new page variant dialog, enter the page variant name and click Next.

  4. In the Create your audience dialog, in Build mode, enter the name of your audience and click Add first condition.

  5. In the Conditions right-hand panel, click Custom, then click Create.

    Screenshot of the audience builder with the custom condition option.
  6. Enter a name for the new condition.

  7. 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:

    (function () {
      const topic = "AI";
      const requiredScore = 0.5;
      const pageName = "AI Summit 2026 registration";
    
      const affinityScore = profile?.traits?.affinities?.[topic]?.score ?? 0;
      const hasViewedPage = profile?.sessions?.some(session => 
        session?.events?.some(event => event?.customData?.page === pageName)
      ) ?? false;
    
      return affinityScore > requiredScore && hasViewedPage;
    })();
  8. Click Save to apply your changes. After saving your custom condition, make sure to define the condition output using the appropriate parameter names.

  9. 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.

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