track

Track an event in the user session.

This method tracks an event for analytics and personalization purposes.

Signature

This method has the following signature:

tracker.track(event: string, payload: EventPayload): Promise<Event>

The return is a Promise that resolves to the tracked event after successful transmission.

Example

Here is a basic example of how to use this method:

import croct from '@croct/plug';
croct.tracker.track('goalCompleted', {goalId: 'newsletter-sign-up'});

Parameters

The following list describes the supported parameters:

event
string

The name of the event to track.

For a list of supported events, see the  Event reference.

payload
object

The payload of the event for the specified event type.

For more information about the payload structure, see the  Event reference.