API Reference / API Parameters / userToken
Type: string
Engine default: user ip address
Parameter syntax
userToken => 'YourUserAnonymousId'

Can be used in these methods:

About this parameter

Associates a certain user token with the current search.

Sending a user token associates a search with a certain user. This is essential for features like personalization. The user token should match the userToken in events sent to the Insights API (also known as the anonymous user token, or session user token).

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

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?