User Affinities in practice

For a description of affinities see Affinities

In the following example, the system is set up to support users having favourites and products that need to be replenished from time to time.

  1. Enable personalization. This is done via the UI's General Settings page.

  2. Set affinities on SKUs. This can be done via the SKU bulk create or patch endpoint.

    {
      "skus": [
        {
          "skuNo": "lipgloss-8695",
          "name": "lipgloss",
          ...
          "commercialAffinities": {
            "favorite-lipgloss-8695": 1.00,
            "replenishment-lipgloss-8695": 1.00,
          }
        }
      ]
    }
    

    Note

    Note that the product has two commercial affinities that include the SKU number as part of it. This allows individual boosting of favourites and replenishment. The score is set to 1.00 as this product matches 100%.

  3. Individual user affinities need to be set using the bulk user affinity endpoint. This must be done in two requests, one to set the favourites and one to set the replenishment affinities.

    {
      "dataSource": "favorite",
      "userAffinities": [
        {
          "userId": "user-1",
          "affinities": {
            "favorite-shampoo-4652": 0.25,
            "favorite-lipgloss-8695": 0.50,
          }
        }
      ]
    }
    
    {
      "dataSource": "replenishment",
      "userAffinities": [
        {
          "userId": "user-1",
          "affinities": {
            "replenishment-shampoo-4652": 0.33,
            "replenishment-vitamins-b-4569": 0.50,
          }
        }
      ]
    }
    
  4. Set up affinity source boosting for "favorite" and "replenishment" in the context preview in the UI.