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('', function(box) {
   console.log("Showing box " +;

Available events

The following events are available. Fires when a box becomes visible
box.dismiss Fires when a box is manually dismissed
box.hide Fires when a box is hidden


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

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

Please note that Boxzilla initializes on the window.load event. This means that if you are trying to show a box immediately after loading a page, you have to ensure your code runs after this event is fired:

window.addEventListener('load', () => {

Was this article helpful? ·