Developers

TrackEvent

trackEvent

Usage

Use this method to track a specific event:

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

event

event is the event you want to register.

data

data is the data related to the registered event.

Note

For more information, see the Tracking Events section.

Example

To track a click, start with the following command:

  searchClient.trackEvent('click',{
       code: searchResultByID.tracking.clickCode,
      });

However, note that this is not enough: you also need to track the sessionToken. The full example looks like this:

              searchClient.generateSession().then(function (response) {
                searchClient.setSession(response.sessionToken);
                searchClient.trackEvent('click',{
                  code: searchResultByID.tracking.clickCode,
                });
              });
Note

Without get/set session, tracking the event always returns a 401 error.