Skip to main content
After preparing your index, you should focus on your event implementation. To enable a personalized search experience, the Advanced Personalization feature must learn about your users. This means tracking their interactions with your website or app through events.
This feature isn’t available on every plan. Refer to your pricing plan to see if it’s included.

Send events to Algolia

For more details, see:

Attach user tokens to events

To ensure that Advanced Personalization can understand each user’s journey and continuously improve their personalization experience, you must attach a user token to each event. For user profiles to be found and retrieved at search time, you should persist anonymous user tokens and authenticated user tokens across sessions. User profiles are identified by the userToken property sent with Insights events.

Attach user tokens with InstantSearch

If you’re using Algolia’s UI libraries, you can attach user tokens with InstantSearch.

Attach user tokens with an API client

Use the Search Insights library’s setUserToken method to send the user token with every event or for each event.

Send with every event

JavaScript
// Set a global user token
aa('setUserToken', 'user-1');

// Send a click event associated with "user-1"
aa('clickedObjectIDs', {
  index: 'movies',
  eventName: 'Added to favorite',
  objectIDs: ['movieID1'],
});

Send with each event

JavaScript
// Send a click event associated with "user-2"
aa('clickedObjectIDs', {
  userToken: 'user-2',
  index: 'movies',
  eventName: 'Added to favorite',
  objectIDs: ['movieID1'],
});

Events properties

Events must be linked to an existing index. Events with object IDs that aren’t found in an index are ignored when computing user profiles. Events without a queryID can be used in personalization, but they won’t be reported in Algolia’s search analytics. You can send events in batches. Their timestamps must be set to the time of their collection.

Send conversion events with subtypes

When your users perform conversion events, you need to send a special conversion event with the relevant subtype (addToCart or purchase).

Check events implementation

  1. Visit your website and interact as a user: generate some events.
  2. Check the Events debugger in Algolia’s dashboard to verify that your events are being sent.
I