Skip to main content
When certain events trigger in our UI, we send you a widget event. These events have the information you need to take action in your codebase in response to the event. If integrating on mobile through a WebView, an alternative to standard widget events is required. See Events in Mobile WebViews for more information. It’s your responsibility to add a listener to capture the properties of these triggered events and handle what happens next.
Don’t use widget events for keeping data in sync between platforms. Webhooks are a more reliable way of coordinating events between your servers and MX servers.
Widget events from MX have the following properties:
  • The mx field that lets you filter out widget events coming from MX.
  • The type field that identifies what the event represents at a high level.
  • The metadata object field that has information related to the type.
Here’s an example integration that lets you listen to the events we send:
Example Integration

Events in Mobile WebViews

MX has developed a URL-based updating mechanism to replace event messages that are available to other desktop implementations. You can capture this URL and use the information provided in it to build the necessary logic for coordinating application events. When requesting a widget URL, you must include the is_mobile_webview field with a value of true in your request to access WebView event messages. If you don’t want to handle these events, either set the is_mobile_webview value to false or don’t include this flag. For the Micro Insights Widget, this URL is delivered via a window.location = "mx://pulse/micro-carousel/cta?metadata=<metadata as an encodedURI JSON string>" call within the iFrame. You must capture this URL, parse out the path and query string, then JSON decode the metadata field. When decoded, the metadata contains the beat_guid, beat_template, and user_guid fields.
Not capturing this URL can cause the app to break.

Application Events

Widget Load

This event triggers when the widget loads.

Widget Ping

This event keeps the widget session alive.

Widget focusTrap

This event is triggered when popover content which traps the focus onto a particular element is opened or closed, but only in the case that no other popover content is already open. This event is triggered by some drawers, menu buttons, and modals.

Insights Widget Events

When displayed in the Insights Widget, some insights contain a call to action (CTA) that directs the user to the appropriate location by default, but others require you to send the user somewhere else to complete an action. Here’s the process:
  1. We detect that a user has selected a CTA on one of our insights that requires you to send the user somewhere outside of our widget.
  2. We send you a UI event to let you know that a user has selected this CTA. Each event contains base metadata fields, and some events contain fields specific to individual insight templates. Refer to Table 1 for details about these fields.
  3. The listener you create for this event sends the user to the appropriate location within your mobile app or website based on the details we sent through the UI event.
Table 1. Event fields
You must create listeners for each of the insight templates described in Table 2 that MX has enabled for you.
Table 2. Templates and associated actions

Micro Insights Widget Events

The Micro Insights Widget has two UI events. One event triggers when the user selects the View all CTA in the Micro Insight Widget’s header. If you have the header enabled, you must add a listener for this event that sends the user to the Insights Widget. Here’s what this event looks like:
Example
Another event is triggered when the user selects the Learn more CTA. You must add a listener for this event that sends the user to the Insights Widget. In this event, the metadata includes a beat_guid. Use this GUID in your widget URL request for the Insights Widget so the specified insight shows at the top of the insights feed. See Move Insight to Top of Feed for more info. Here’s an example of what this event looks like:
Example