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

# All Methods

> Complete reference for every method on window.zenstep.

## Method reference

| Method       | Parameters                                        | Returns | Description                         |
| ------------ | ------------------------------------------------- | ------- | ----------------------------------- |
| `identify()` | `userId: string`, `attributes?: UserAttributes`   | `void`  | Associate session with a known user |
| `track()`    | `event: string`, `data?: Record<string, unknown>` | `void`  | Send a custom behavioural event     |

***

## identify()

Associate the current browser session with a known user ID and optional attributes.

```typescript theme={null}
identify(userId: string, attributes?: UserAttributes): void

interface UserAttributes {
  [key: string]: string | number | boolean | undefined;
}
```

**Full reference:** [identify()](/snippet-api/identify)

***

## track()

Send a custom behavioural event. Events are stored in analytics and can be used in targeting rules.

```typescript theme={null}
track(event: string, data?: Record<string, unknown>): void
```

**Full reference:** [track()](/snippet-api/track)

***

## Internal properties

### `_q`

```typescript theme={null}
_q: Array<["identify" | "track", unknown[]]>;
```

The pre-init call queue. Before the snippet has evaluated, calls to `identify()` and `track()` are pushed here as tuples. After initialisation, the queue is drained and `_q` is an empty array.

**Do not write to `_q` directly** — use the methods above.

***

## TypeScript declaration

Copy this global declaration into your project to get full type safety:

```typescript theme={null}
// global.d.ts
interface ZenstepUserAttributes {
  [key: string]: string | number | boolean | undefined;
}

interface ZenstepAPI {
  identify: (userId: string, attributes?: ZenstepUserAttributes) => void;
  track: (event: string, data?: Record<string, unknown>) => void;
  _q: Array<["identify" | "track", unknown[]]>;
}

declare global {
  interface Window {
    zenstep?: ZenstepAPI;
  }
}

export {};
```

***

## Error handling

All methods catch errors internally. If the Zenstep snippet encounters an error processing an `identify()` or `track()` call, it logs a warning to the browser console (`[Zenstep] identify error: ...`) and continues. Your application code will never throw due to a Zenstep call.

***

## Versioning

The snippet API follows semantic versioning. Breaking changes to the public API surface will increment the major version and be announced in the changelog. The CDN URL (`/v1/snippet.js`) pins you to the v1 major version — you will receive backward-compatible updates automatically.
