Guides / Getting insights and analytics / Personalization / Personalizing results

Enabling Personalization

Introduction

To take advantage of personalized search results, you need to send the enablePersonalization and userToken search parameters. The way to do this depends on your implementation of Algolia, and whether or not you use InstantSearch. You can also set enablePersonalization in your index settings instead of sending it as a search parameter. This way, every search on your index uses Personalization.

InstantSearch

With InstantSearch, you can enable personalization in two different ways. You only need to choose one of them:

  • during initialization of your InstantSearch instance
  • or by making use of the configure widget.

Either way, you need to use the enablePersonalization parameter if you didn’t set in your index settings already. You also have to provide the userToken you’re using to send personalization events.

During Initialization

During the setup of your InstantSearch instance, you can pass (almost) any search parameter, including enablePersonalization. To do this, you can pass an object containing enablePersonalization and userToken keys.

1
2
3
4
5
6
search.addWidgets([
  instantsearch.widgets.configure({
    enablePersonalization: true,
    userToken: 'user-1234',
  }),
]);

Using the configure widget

1
2
3
4
5
instantsearch.widgets.configure({
  hitsPerPage: 8,
  enablePersonalization: true,
  userToken: 'user-1234',
});

API Clients

If you’re using one of our API clients, you can use the enablePersonalization parameter in the search method if you didn’t enable Personalization in your index settings yet. You also have to provide the userToken that you’re using to send personalization events.

1
2
3
4
$index->search('query', [
  'enablePersonalization' => true,
  'userToken' => '123456'
]);

Did you find this page helpful?