track() method sends a custom event to Usertour for the currently identified user.
Use it when you want to record meaningful product actions from your app, such as a project being created, a subscription being upgraded, or a teammate being invited.
Before calling track(), the user must already be identified with identify() or identifyAnonymous().
If the event name or event attributes do not exist yet in Usertour, their definitions are created automatically the first time they are received.
Parameters
The event name to track. This maps to the event’s
codeName in Usertour. We recommend using stable, descriptive names such as project_created, subscription_upgraded, or teammate_invited.Optional event attributes to store alongside the event. These can be used later in analytics and event-based conditions.
Optional settings that control how the event is associated in Usertour.
By default, if the current user has also been associated with a company through
group(), the tracked event is linked to both the user and the current company. Set userOnly: true to record the event only for the user.Returns
APromise that resolves when the event has been accepted by Usertour.
Examples
Track a simple product event
Track an event with attributes
Track a user-level event even when a company is set
Notes
- Call
identify()oridentifyAnonymous()before usingtrack() - Event names should stay stable over time so analytics and conditions remain reliable
- If
group()has been called, events are associated with the current company unlessuserOnly: trueis set - Event and event-attribute definitions are created automatically when first received