Browser SDK

track

Record meaningful user behavior in the browser.

Signature#

FieldRequiredTypeDescription
eventName or eventtruestringEvent name.
propertiesfalseobjectBehavior or outcome data.
optionsfalseobjectContains identity, context, timestamp, integration, message ID, or extra context fields.
callbackfalsefunctionReceives 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.

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.

FieldRequiredTypeDescription
elementstrueElement | Element[] | jQuery-like collectionDOM element collection to bind.
eventtruestring | functionEvent name, or function receiving the element and returning an event name.
propertiesfalseobject | functionProperties, or function receiving the element and returning properties.
optionsfalseobjectSame 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.

FieldRequiredTypeDescription
formstrueHTMLFormElement | HTMLFormElement[] | jQuery-like collectionForm elements to bind.
eventtruestring | functionEvent name or function, as with trackLink.
propertiesfalseobject | functionProperties or function, as with trackLink.
optionsfalseobjectOptions, 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.