track
Record meaningful user behavior in the browser.
Signature#
| Field | Required | Type | Description |
|---|---|---|---|
eventName or event | true | string | Event name. |
properties | false | object | Behavior or outcome data. |
options | false | object | Contains identity, context, timestamp, integration, message ID, or extra context fields. |
callback | false | function | Receives the dispatched context. |
The object form is also supported. properties defaults to {}. A missing event name throws Event missing.
When to call#
Call track when a meaningful action occurs: a workflow step opens or completes, a feature is used, a payment is attempted, or an outcome occurs.
Do not call it for every click or keystroke unless opt-in instrumentation is intended. Do not send user-entered content.
Track links#
Use trackLink to record a meaningful link click while preserving normal navigation. It binds tracking to existing link elements; it is not a CSS-selector-based click listener.
Unlike regular track, trackLink delays the browser's normal navigation by up to 500 ms while the track request completes or times out. This gives the event time to reach its destination before a fast redirect or page unload interrupts delivery. Use regular track for actions already handled by application code; use trackLink when the browser's default link navigation could unload the page immediately.
| Field | Required | Type | Description |
|---|---|---|---|
elements | true | Element | Element[] | jQuery-like collection | DOM element collection to bind. |
event | true | string | function | Event name, or function receiving the element and returning an event name. |
properties | false | object | function | Properties, or function receiving the element and returning properties. |
options | false | object | Same options as track. |
Pass elements, not CSS selectors. The helper binds a click handler to each element.
In React, use a ref because trackLink requires the DOM element:
On a normal navigation, the helper prevents the default action, sends the track event, then continues navigation when tracking resolves or the timeout expires. Links opened in a new tab are not delayed.
Track forms#
Use trackForm to record a meaningful form submission while allowing the form to continue submitting after tracking. It binds tracking to existing form elements.
Similar to trackLink, trackForm delays the browser's default form submission by up to 500 ms while the track request completes or times out. This gives the event time to reach its destination before navigation or page unload interrupts delivery. Use regular track for submissions already handled by application code; use trackForm when the browser's default submission could unload the page immediately.
| Field | Required | Type | Description |
|---|---|---|---|
forms | true | HTMLFormElement | HTMLFormElement[] | jQuery-like collection | Form elements to bind. |
event | true | string | function | Event name or function, as with trackLink. |
properties | false | object | function | Properties or function, as with trackLink. |
options | false | object | Options, as with trackLink. |
Pass elements, not CSS selectors.
The helper prevents the default submission, sends the track event, then submits the form when tracking resolves or the timeout expires. Do not put passwords, payment data, or raw form values in properties; send only safe metadata.
In React, use a ref:
The default wait timeout is 500 ms. Configure the SDK timeout when a different maximum delay is appropriate, for example analytics.timeout(1000).
Payment funnel#
Use a backend event for authoritative payment success when possible.
Options example#
Normalized payload#
Never include passwords, secrets, tokens, card data, raw form values, search queries, messages, or prompts.