> ## Documentation Index
> Fetch the complete documentation index at: https://onlook.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# track()

> Start a tracked session and return a Session object.

## Signature

```ts theme={null}
function track(userId: string, config?: OnlookConfig): Session
```

## Parameters

<ParamField path="userId" type="string" required>
  A stable identifier for the user. Can be an email, UUID, or any string. Not stored as PII — hashed before transmission.
</ParamField>

<ParamField path="config" type="OnlookConfig">
  Optional configuration object. See [SDK Overview](/sdk/overview#configuration) for all options.
</ParamField>

## Returns

A `Session` object. See [Session](/sdk/session).

## Example

```ts theme={null}
import { track } from '@onlook/core'

const session = track('user_123', {
  context: 'onboarding',
  threshold: 50,
  signals: { face: true, idle: 20 },
})

session.on('drop', ({ score }) => {
  triggerIntervention(score)
})
```

## Notes

* Calling `track()` twice with the same `userId` returns the existing session.
* Call `session.stop()` when the user navigates away to flush the final score.
