Skip to main content

Sessions and user identity

Sessions provide the foundation for consistent personalization. By initializing a session, user interactions and recommendations can be linked to a stable identifier — enabling long-term analytics, segmentation, and CRM activation.

Initializing a session

Use initSession to establish a user identity at the start of each interaction.
The returned userId and sessionId should be reused throughout the session and across subsequent API calls.

Why sessions matter

Sessions connect the dots between exploration, preference capture, and recommendations:
  • Recommendations improve over time — passing userId to recommendation queries lets the API learn from prior interactions
  • Preferences persist across sessions — the same userId links behavior across visits, devices, and channels
  • CRM activation — session data can be exported for email campaigns, lifecycle journeys, and segmentation

Anonymous vs identified users

You can initialize sessions with or without a known user identity:
  • Identified users: Pass your platform’s user ID (UUID, email hash, or CRM identifier) to link sessions to a known profile
  • Anonymous users: Generate a temporary identifier for the session. If the user later registers, you can re-initialize with their permanent ID to merge behavior

Using session data in queries

Once a session is initialized, pass the userId to queries that support personalization:
See Recommendations for the full recommendation guide, and CRM & Personalization for how to extend sessions beyond the website.