Event Tracking Methods
Methods for tracking events, identifying users, and managing user sessions.track
Track a custom event with optional properties.string
required
Event name. Use descriptive names like
Button Clicked or Purchase Completed.EventProperties
Optional event properties. Can include any JSON-serializable data.
Returns
void
Example
identify
Identify a user and associate events with them.string
required
User ID. Should be a unique identifier for the user.
UserTraits
Optional user traits. Properties that describe the user.
Returns
void
Example
page
Track a page view.string
Optional page name. If not provided, will use the current page path.
EventProperties
Optional page properties.
string
Optional page category.
Returns
void
Example
group
Associate a user with a group or organization.string
required
Group ID. Should be a unique identifier for the group.
GroupTraits
Optional group traits. Properties that describe the group.
Returns
void
Example
alias
Merge anonymous and identified user identities.string
required
New user ID (the identified user ID).
string
Previous user ID (usually the anonymous ID). If not provided, will use the current anonymous ID.
Returns
void
Example
reset
Reset user identity and start a new session. Useful when a user logs out.Returns
void
Example
flush
Force immediate sending of all queued events.Returns
Promise<void>
