Pass the events in the options object.
The events are automatically pushed to the data layer array.

ticketFocused
Fired when the focus changes from one ticket to another.

destroyed
The widget instance has been removed from both the memory and the DOM.

visiblity
Fired when the chat box becomes visible or hidden.

var widgetOptions = {
    events: {
        'ticketFocused': (nextTicketId) => console.log("Next focused ticket: " + nextTicketId),
        'destroyed': () => console.log("Widget destroyed."),
        'visiblity': (isVisible) => console.log(isVisible ? "Widget is visible" : "Widget is hidden")
    }
};