JavaScript events

The Boxzilla plugin comes with several JavaScript events for you to hook into whenever certain box events occur.

You can run register your JavaScript functions by calling the Boxzilla.on( eventName, callback ) function. When the specified box event occurs, your function will be executed.

Here's an example where we run a function whenever a box is shown to a visitor.

Boxzilla.on('box.show', function(box) {
   console.log("Showing box " + box.id);
});

Available events

The following events are available.

ready Fires after Boxzilla is done initialising
box.show Fires when a box becomes visible
box.dismiss Fires when a box is manually dismissed
box.hide Fires when a box is hidden

Example

The following example demonstrates how to track an event with Hubspot.

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["trackEvent", {
    id: "BOXZILLA_SHOW",
    value: box.id
}]);

Was this article helpful? ·