Skip to main content

Events

The Selektable SDK communicates with the widget iframe using the browser’s postMessage API.
You don’t need to handle these events directly. The SDK manages them automatically. This reference is for debugging purposes.

Key events

The SDK handles several categories of events between your page and the widget:
CategoryDescription
LifecycleWidget loading, opening, and closing
Product dataSending product information to the widget
Cart actionsAdd to cart, view cart, and checkout interactions
IdentityPassing visitor identity to the widget

Listening for widget close

You can listen for when a customer closes the widget, for example to trigger analytics:
window.addEventListener('message', function (event) {
  if (
    event.data &&
    event.data.type === 'widget:modal-close'
  ) {
    // Customer closed the widget
    console.log('Widget closed');
  }
});

Security

The SDK validates the origin and structure of all incoming messages. Messages from untrusted sources are silently ignored.