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.
Overview
Zenstep uses a queue pattern (similar to the GA4 dataLayer) to handle calls made before the snippet bundle has evaluated. This means you can safely callwindow.zenstep.identify() and window.zenstep.track() anywhere in your page — even in <head> scripts that run before <body>.
How it works
When the snippet’s<script> tag is added to the page, the browser begins loading snippet.js asynchronously. In the meantime, the snippet installs a lightweight stub on window.zenstep:
snippet.js finishes loading, it:
- Reads
window.zenstep._q - Replays each queued call with the real implementation
- Replaces the stub with the full API
Why this matters
You do not need to wait for the snippet to load before callingidentify(). Call it wherever the user data is available — in a layout component, on DOMContentLoaded, or even inline in <head>:
Queue inspection
You can inspect the queue at any time viawindow.zenstep._q. Each entry is a tuple of [methodName, argsArray]:
_q is an empty array (all calls have been replayed).
Order guarantee
Calls are replayed in FIFO order. If you callidentify() before track(), the queue processes them in that order. This matters because track() uses the identity set by the most recent identify() call.
Edge cases
Snippet fails to load — if the CDN is unreachable,snippet.js never evaluates. Calls remain in _q but are never replayed. Your page continues to function normally — Zenstep fails silently.
Multiple identify() calls — if you call identify() twice before the snippet loads, both are queued. The second call merges attributes into the first (Zenstep does not replace the full identity object on re-identification).