'track' Method
Custom Intempt Method for tracking user actions and events within an application
The track method is specifically designed to log various user actions and events within an application. This method collects detailed information about events based on provided parameters and records them for analysis, assuming the user has opted in and the data meets validation criteria.
Usage example
const trackParams = {
eventTitle: 'Product View',
data: {
productId: 'XYZ123',
productName: 'Gadget Pro',
price: '199.99'
}
};
intempt.track(trackParams);
In this example, the track method is used to log a product view event with additional data about the product, such as its ID, name, and price.
Declaration
The track method is declared as follows in TypeScript, highlighting that it does not return any value:
track(params: TrackParams): void
Params
The parameters for the track method are encapsulated within the TrackParams
type, allowing for extensive customization and detailed event tracking:
type TrackParams = {
eventTitle: string, // Title of the event being tracked.
data: {[key:string]: any} // Additional data related to the event in a key-value pair format.
}
Forbidden event names for use
Certain event names are reserved or forbidden to prevent conflicts or misidentification in the tracking system. They include common actions and default functionalities that are automatically tracked or handled differently:
- auto-track: Reserved for automatic tracking mechanisms.
- view page: Used specifically for page view tracking.
- leave page: Indicates a user leaving a page, automatically tracked.
- change on: Indicates a user leaving a page, automatically tracked.
- click on: Indicates a user leaving a page, automatically tracked.
- submit on: Used for tracking form submissions.
- identify: Special use within the identify function itself.
- consent: Special use within the identify function itself.
These names should not be used as custom event titles to avoid system errors and ensure accurate event categorization and analysis.
Updated about 3 hours ago