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.
JavaScript:
-
new Coral.tracking()
Methods
-
Coral.tracking.addListener
-
- Parameters:
-
Name Type Description callback Coral.tracking~trackingCallback The callback to execute.
-
Coral.tracking.removeListener
-
- Parameters:
-
Name Type Description callback Coral.tracking~trackingCallback
-
Coral.tracking.track
-
- 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}
Add a tracking callback. This will be invoked every time a tracking event is emitted.
Removes a tracker.
Notify all trackers subscribed.
Type Definitions
-
instance.trackingCallback
-
- Parameters:
-
Name Type Description trackData Object Object containing the data to be tracked. It contains the properties type
,eventType
,element
andfeature
.event CustomEvent Underlying event that was generated by the user component HTMLElement Component that triggered the tracking event.
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.