Developers

Track

Usage

Use this method to track a specific event:

client.track(event:String, data:Object);

Events and the specific data for each event are specified in the tracking events section of the Developers Portal.

Note

Remember to set up the session before calling this function.

To start a session see methods generateSession and setSessionToken.

Mandatory parameters

Name Type Description
Event string Name of the event you want to track

Option

Note

Depending on the event, this may be mandatory.

Name Type Default Description
data Object Object with the values you want to track.

Response data format

This method calls the Knowledge API’s POST /inbtrck/events endpoint. Please refer to the Responses section of that endpoint on the Knowledge API Routes page for the response format.

Example

The following example is set to track click events in content issued from a 'dinosaur' search query:

client.search('dinosaur').then(function(response){
    client.track('click', {
        // Each result holds a click token inside the tracking object.
        code: response.data.results[0].tracking.clickCode,
    });
});