Algolia DevCon
Oct. 2–3 2024, virtual.
Guides / Personalization / AI Personalization (beta) / Configure personalization / Prerequisites

Prepare your event implementation

AI Personalization is a beta feature according to Algolia’s Terms of Service (“Beta Services”).

Once you’ve prepared your index structure, you should focus on your event implementation. To enable a personalized search experience, AI Personalization must learn about your users. This means tracking their interactions with your website or app through events.

Send events to Algolia

Attach user tokens to events

To ensure that AI 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

1
2
3
4
5
6
7
8
9
// 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

1
2
3
4
5
6
7
// 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 objectIDs that are not found in an index are discarded in the user profiles computation.

Events without a queryID can be used in personalization. However, these events won’t be reported in Algolia search analytics.

Sending events in batches is allowed. The timestamps of batched events 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.
Did you find this page helpful?