Coral.tracking provides the possibility to track Coral components using custom analytics trackers.

Coral.tracking API

Constructor

Signature function used to track the usage of Coral components. By default, there is no out of the box implementation as tracking is agnostic of the underlying technology. You need to implement a new tracker and add it with: Coral.tracking.addListener(fn(){ }); The fn() callback will receive multiple arguments:
  • trackData - an object with fixed structure. Eg. {type: "button", eventType: "click", element: "save settings", feature: "sites"}
  • event - the CustomEvent or MouseEvent details object.
  • component - the Coral.Component reference object.
Using the above data you can map it to your own analytics tracker.

JavaScript:

new Coral.tracking()

Methods

Coral.tracking.addListener

Add a tracking callback. This will be invoked every time a tracking event is emitted.
Parameters:
Name Type Description
callback Coral.tracking~trackingCallback The callback to execute.

Coral.tracking.removeListener

Removes a tracker.
Parameters:
Name Type Description
callback Coral.tracking~trackingCallback

Coral.tracking.track

Notify all trackers subscribed.
Parameters:
Name Type Optional Description
eventType String No
Eg. click, select, etc.
targetType String No
Eg. cycle button, cycle button item, etc.
event CustomEvent No
component Coral.Component No
childComponent Coral.Component Yes
Optional, in case the event occurred on a child component.
Returns:
if the event was dispatch to at least 1 tracker. {Boolean}

Type Definitions

instance.trackingCallback

Executes the callback when ever there is an interaction inside the component that needs to be tracked. This can be used to get insight on how users interact with the page and the features that available.
Parameters:
Name Type Description
trackData Object Object containing the data to be tracked. It contains the properties type, eventType, element and feature.
event CustomEvent Underlying event that was generated by the user
component HTMLElement Component that triggered the tracking event.