🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API Reference / API Parameters / userToken
Type: string
Engine default: user ip address
Parameter syntax
userToken => 'YourCustomUserId'

Can be used in these methods:

About this parameter

Associates a certain user token with the current search.

Sending a user token will associate a search with a certain user. The insights taken from this could be used in combination with personalization for example.

Make sure to use the same user token for your events (Insights API) and search requests (Search API).

  • If you send the authenticatedUserToken with your events, send the same value with your search requests.
  • If you send the userToken with your events, send the same value with your search requests.

For more information about the correct format of a user token, see userToken (Insights API).

Examples

Set the user token

1
$index->search('query', ['userToken' => '123456'])

Enable personalization for the current search and specify a user token

1
2
3
4
$index->search('query', [
  'enablePersonalization' => true,
  'userToken' => '123456'
]);
Did you find this page helpful?