Internally we use events to track whether a component has been seen or not, or in the case of a control group, if the component would have been seen if it wasn't for the control group. Based on these events we can make our insights pages. The events are also emitted from our script itself. This allows you to listen from them programatically and forward them to any analytics service you are using.
The events are emitted on the document using the key unless-event
. The event detail has the following fields:
Field name | Description |
---|---|
event_type | The type of the event, usually experience_started . |
experience_name | The name of the experience/component that is started. |
experience_id | The internal ID of the experience/component. |
experience_type | The experience type, this can be either Component or On-site . |
experience_test | The test type of the visitor. Either Control , Participant or the name of the variant. |
The following example will simply print the detail of the event:
// make sure to add the event listener to the document before loading the Unless script to make sure you won't miss any events.
document.addEventListener('unless-event', (e) => console.log(e.detail))