Fires whenever an event has occurred.
Description
The trackEvent
lifecycle event is fired whenever the visitor triggers an event.
You can use this API if you want to track conversions in an external analytics platform.
You can also use this to manually activate an experiment after a particular event has occurred.
var trackEvent = function(trackEvent);
function onTrackEvent(event) {
console.log("The event " + event.data.name + " was tracked");
}
window.optimizelyEdge = window.optimizelyEdge || [];
window.optimizelyEdge.push({
type: "addListener",
filter: {
type: "analytics",
name: "trackEvent"
},
handler: onTrackEvent
});
Parameters
This table provides general information about required and optional parameters.
Parameter | Type | Description |
---|---|---|
trackEvent required | object | The data relevant to the |
trackEvent.type | string |
|
trackEvent.name | string |
|
trackEvent.data | object | Data associated to this event. You can use this object to determine which event was triggered. |
trackEvent.data.type | string | The type of the tracked event (e.g. "custom" for custom events, "pageview" for Page activated events). |
trackEvent.data.name | string | The name of the tracked event. |
trackEvent.data.apiName | string | The apiName of the tracked event. Note that for "pageview" events, this is the |
trackEvent.data.category | string | The category of the tracked event or page. |
trackEvent.data.metrics | object | Metrics attached to the event, if any. |
trackEvent.data.metrics.revenue | number or unidentified | Revenue value associated with the event, if any. |
trackEvent.data.tags | object | Map of tag name to tag value. |