Skip to main content
Use track(), on(), and once() to track custom events and listen for SDK events.

track()

on() / once()

Event Types

Tracking Events

Basic Usage

With Callback

With Beacon API

Force use of the Beacon API for reliable tracking during page unload:

track() Method

Signature

Parameters

Options

Return Value

Returns a Promise that resolves with the event object:

Event Examples

Event Listeners

on() - Persistent Listener

Listen for all occurrences of an event:

once() - Single Listener

Listen for only the first occurrence:

Pattern Matching

Use regex to match multiple event types:

Removing Listeners

Store the listener reference to remove later:

Standard Event Types

The SDK defines these standard event types:
Standard events (Pageview, etc.) are tracked automatically by the web addon. Use track() for custom events.

SDK Events

Listen for internal SDK events:

Best Practices

Track meaningful user actions, not every interaction:

Tracking on Page Unload

For events that must be tracked when the user leaves:
The web addon automatically tracks PageviewComplete on page unload, so you don’t need to track basic exit events manually.

Debugging

Enable debug mode to see all tracked events:
Console output:

Troubleshooting

Problem: track() called but no events in dashboard.Solutions:
  • Check consent is granted (if consentRequired: true)
  • Verify SDK is initialized
  • Enable debug mode to see if events are accepted
  • Check for JavaScript errors before track call
  • Allow processing time (events may take minutes to appear)
Problem: Success/error callbacks not called.Solutions:
  • Verify callback functions are defined correctly
  • Check for errors in callback code
  • Ensure SDK is loaded before tracking
Problem: Event tracked but some properties missing.Solutions:
  • Check property names match expected schema
  • Verify property types are correct
  • Look for undefined values being passed
  • Check for typos in property names

Event Properties

Structure event data

Pageview Tracking

Automatic pageview tracking

Cohorts

Events power cohort membership

Connectivity Events

Event schema documentation