Skip to main content
Required ACL: search Use this method to automatically send the authenticatedUserToken with every event. For more information, see User token.

Examples

For more information about initializing the JavaScript Insights client aa, see Initialize the Insights client.
JavaScript
import aa from "search-insights";

aa("init", {
  appId: "YourApplicationID",
  apiKey: "YourSearchOnlyAPIKey",
  useCookie: true,
});
When user logs in, set the authenticated user token to the user ID coming from your system.
JavaScript
aa("setAuthenticatedUserToken", "YourUserID");
Now, both the anonymous and authenticated tokens will be sent with each event to ensure that data collected when users weren’t authenticated isn’t lost. When users log out, you can unset the authenticated token by passing undefined.
JavaScript
aa("setAuthenticatedUserToken", undefined);

Parameters

authenticatedUserToken
string | undefined
required
Pseudonymous identifier for authenticated users.
Don’t include personally identifiable information in user tokens.
See also: User token
⌘I