The user token sent with search queries must match the userToken parameter sent with events in order for Algolia's AI features to function efficiently. This means you should be sending the anonymous/session user token with search queries. If a userToken is not explicitly set at query time, Algolia defaults to setting one based on the request's IP address.
Our current recommendation is:
- Send the same anonymous/session
userTokenin both the search and eventsuserTokenparameters - If a user logs in (authenticated users), send the
authenticatedUserTokenin theauthenticatedUserTokenevents parameter -
Do not replace
userTokenwith the authenticated user token in search queries or events - Following this means:
- both the anonymous and authenticated user tokens will be sent with each event to ensure that data collected when users weren’t authenticated isn’t lost
- user profiles for Personalisation continue to be updated, as profiles are currently built using
userToken
More info on these parameters can be found here:
- User Token: https://www.algolia.com/doc/api-reference/api-parameters/userToken/#how-to-use
- Authenticated User Token: https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/#authenticated-user-token
Useful Guides:
For a full list of common userToken issues, troubleshooting topics and best practices, see our summary article here.