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

> ## Agent Instructions
> Read /start/capabilities before choosing an integration. Use the deployed server’s tools/list for current tool inputs.

# Browser API

> Track events, read the visitor ID, and manage consent.

## Track an event

```js theme={null}
// Run after your application has confirmed success.
window.dynamite = window.dynamite || [];
window.dynamite.push(['track', 'order_completed', { value: 79 }]);
```

Configure an event goal with the same name. `value` is optional and numeric. Choose a consistent unit for your reporting.

Use `push` whether the script has loaded or is still loading.

## Read the visitor ID

```js theme={null}
const api = window.dynamite;
const visitor = api && !Array.isArray(api) ? api.visitor() : null;
if (visitor) {
  console.log(visitor.id, visitor.sessionId, visitor.group);
}
```

Returns `null` before the runtime is ready. The ID represents an anonymous browser profile. Optional groups are `personalized`, `holdout`, or `off`.

## Set consent

```js theme={null}
window.dynamite = window.dynamite || [];
window.dynamite.push(['consent', true]);
// Later, if the visitor withdraws:
window.dynamite.push(['consent', false]);
```

See [Consent](https://docs.usedynamite.com/integrate/consent.md) for startup and withdrawal behavior.

> [accordion] TypeScript contract
>
> ```ts theme={null}
> interface DynamiteApi {
>   track(name: string, properties?: { value?: number }): void;
>   visitor(): { id: string; sessionId?: string; group?: string } | null;
>   consent(granted: boolean): void;
>   push(command: [name: string, ...args: unknown[]]): void;
> }
> ```
>
> Only `track` and `consent` can be queued. Call `visitor()` directly after initialization.

> [accordion] Internal debugging API
>
> `window.IONVisitor` exposes `inspect()`, `refresh()`, `reset()`, `expire()`, and `destroy()`. It is an internal controller for debugging and custom integrations.
>
> ```js theme={null}
> const snapshot = window.IONVisitor?.inspect();
> console.log(snapshot?.status, snapshot?.experiment);
> ```
>
> `refresh()` uses current bindings; it does not discover missing DOM or fetch a new release. The public API has no `identify()`, `setTraits()`, `setVariant()`, `quiz()`, or `onReady()` method.

A purchase-named tracking event is browser measurement, not verified payment history. For application context, use [connected data](https://docs.usedynamite.com/operate/connected-data.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.