Skip to main content

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.

Method reference

MethodParametersReturnsDescription
identify()userId: string, attributes?: UserAttributesvoidAssociate session with a known user
track()event: string, data?: Record<string, unknown>voidSend a custom behavioural event

identify()

Associate the current browser session with a known user ID and optional attributes.
identify(userId: string, attributes?: UserAttributes): void

interface UserAttributes {
  [key: string]: string | number | boolean | undefined;
}
Full reference: identify()

track()

Send a custom behavioural event. Events are stored in analytics and can be used in targeting rules.
track(event: string, data?: Record<string, unknown>): void
Full reference: track()

Internal properties

_q

_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:
// 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.