_shopmsg('addEventListener', 'SomeEventName', function(data) {
  // gets invoked whenever SomeEventName is triggered
  // your callback gets the data sent with the event
  console.log(data);
});

Some developers find it useful to know when an event occurs and be able to respond to it. Since other parts of code may be triggering events, you may not have full control of when or if things happen. For example, you could subscribe to an event when an overlay is shown, or if a checkbox is checked on. You can read more about these built-in events on the Automatic Events page.

_shopmsg('addEventListener', 'SendToMessengerClicked', function(data) {
  if (myWidgetId == data.widget_id) {
    // the send to messenger click happens whenever those plugins are clicked
    // but there can be more than one on the page. use data.widget_id to 
    // distinguish the button you care about from any others
    console.log('myWidget was clicked!');
  }
});