Skip to main content
Once you’ve decided how best to engage your audience, you need to integrate your Insights Widget. This guide explains how to integrate the Insights Widget, Mini Insights Widget, and Micro Insights Widget either on a website using an iFrame or on a mobile app. The examples in this guide use fields that apply only to the Platform API. If you’re using the Nexus API, use the SSO API fields instead.
If you integrated using the Widget Loader, please reference the legacy Widget Loader Configurations guide.
To learn more about each widget, see Insights Widgets.

Integrate using an iFrame

Follow these steps to integrate a widget on a website using an iFrame.
1

Request a Widget URL

Create a backend endpoint that calls the Platform API to generate a widget URL. Set the value of widget_type to your desired widget:
  • Insights Widget: pulse_widget
  • Mini Insights Widget: mini_pulse_carousel_widget
  • Micro Insights Widget: micro_pulse_carousel_widget
See Example API Requests for different configurations.
2

Create an iFrame

Create an iFrame using the widget’s recommended dimensions:Reference the endpoint you created in Step 1 as the src. If you use sandbox, the following attributes must be whitelisted for the widget to work: sandbox="allow-forms allow-same-origin allow-scripts".
Example
3

Create Application Event Listeners

Create listeners for the widget load and widget ping application events.
Example
4

Configure Widget Event Listeners

Configure event listeners for your widget events.Capture and parse the URLs necessary for your widget version:
  • Insights Widget: Refer to the Insights Widget events table to determine which of your enabled insight templates create events that you need to handle.
  • Mini Insights Widget: Capture and parse a URL for when the end user interacts with the View more call to action inside the widget. You must add a listener for this UI event to know when to navigate the end user to the Insights Widget.
  • Micro Insights Widget: Capture and parse two URLs relating to the Micro Insights Widget events:
    • A URL for when the user selects the View all call to action. When the user selects this, you consume the info we send to you in the URL and then send the user to the Insights Widget.
    • A URL for when the user selects the Learn more call to action. When the user selects this, you consume additional information from the URL. This lets you send the user to the Insights Widget with the insight the user selected at the top of the feed.
Example
5

Optional: Filter Insights

You can filter which insights show in a specific Mini Widget instance. See Filter Insights for more information.
Congrats! You’ve integrated your Insights Widget!

Integrate on a Mobile App

To integrate the Insights Widget on a mobile app, follow these steps.
1

Request a Widget URL

Create a backend endpoint that calls the Platform API to generate a widget URL. Set the value of widget_type to your desired widget:
  • Insights Widget: pulse_widget
  • Mini Insights Widget: mini_pulse_carousel_widget
  • Micro Insights Widget: micro_pulse_carousel_widget
Include the is_mobile_webview field with a value of true in your request to access WebView event messages.See Example API Requests for different configurations.
2

Load the URL

Load the URL received from the previous request into a WebView.
3

Build Event Logic

Capture the URLs delivered via window.location = "someurl" calls within the WebView and use the information provided in those calls to build the necessary logic for coordinating events.
All MX URL message events have the mx:// prefix and appear in the format mx://<entity|widget>/<event>?metadata=<metadata as an encodedURI JSON string>. For example: mx://account/created?metadata="{'guid':'ACT-1'}".
You must capture the URL, parse out the path and query string, then JSON decode the metadata field.
4

Handle Widget Load and Widget Ping Events

Capture and parse a URL for the widget load and widget ping application events.
5

Handle Other Widget Events

Capture and parse the URLs necessary for your widget version:Insights Widget: Refer to the Insights Widget events table to determine which of your enabled insight templates create events that you need to handle.Mini Insights Widget: Capture and parse a URL for when the end user interacts with the View more call to action inside the widget. You must add a listener for this UI event to know when to navigate the end user to the Insights Widget.Micro Insights Widget: Capture and parse two URLs relating to the Micro Insights Widget events:
  • A URL for when the user selects the View all call to action. When the user selects this, you consume the info we send to you in the URL and then send the user to the Insights Widget.
  • A URL for when the user selects the Learn more call to action. When the user selects this, you consume additional information from the URL. This lets you send the user to the Insights Widget with the insight the user selected at the top of the feed.
6

Optional: Filter Insights

You can filter which insights show in a specific Mini Widget instance. See Filter Insights for more information.
Congrats! You’ve integrated your Insights Widget!

Common Problems

This section covers some common problems with loading a widget URL into a WebView.
To embed our mobile widgets into a WebView, we require a device width of at least 320 pixels. Depending on the implementation of the WebView, smaller devices may not be provided the full width, leading to display issues.
In apps that run in iOS 8 and later, MX only supports WKWebView. If you previously implemented UIWebView, update your implementation to use WKWebView.Apple recommends this. For more information, see Apple’s developer documentation for UIWebView and WKWebView.
By default, iOS adds additional padding to its WebViews, which sometimes causes problems.To fix this:
  1. Select the WebView providing the widgets in your application and navigate to the size inspector.
  2. Change the layout margins from "Default" to "Explicit".
  3. Update the left and right margins to 0.
  4. Ensure the width is at least 320 pixels.
Whether using WebViews on Android or iOS, most browsers will have a default margin (set in the user agent stylesheet) on the body element when rendering the HTML page responsible for loading a widget. This margin is deducted from the total available width of the containing element, which will cause a problem.To fix this:
  1. Determine the computed width available on the body element. The width available to the iframe can be confirmed by inspecting the iframe injected by MX and typing window.innerWidth in the JavaScript console. The width available to the iframe must be at least 320 pixels.
  2. Confirm the body and html elements have their padding and margin set to 0.
For mobile widgets to render correctly, the viewport must be set in a meta tag on the HTML page used to load the widget URL.The viewport is the size of the window through which a page is seen. It can be smaller or larger than the actual size of a page or device screen.On most mobile devices, the virtual viewport is larger than the actual screen size; web pages are rendered according to the viewport size, then shrunk down to the actual screen size. This helps when viewing pages that aren’t optimized for mobile, but for pages that are optimized for mobile (like the mobile widgets), the viewport meta tag is used to guarantee that the page is rendered properly.Set a meta tag within the <head> element as follows:
Example

Move Insight to Top of Feed

If you embedded the Mini or Micro Insights Widget, you must configure the View More call to action to send users to the Insights Widget. For a seamless experience, we recommend moving the insight they selected to the top of the Insights Widget. To request the Insights Widget with a specified insight displayed at the top:
1

Request a Widget URL

Request the Insights Widget with the insight_guid configuration. Set the value for the insight_guid to the value of the beat_guid you received from the Mini or Micro Insights Widget event.
Platform API Example
2

Use the URL

The response from this Insights Widget request contains the URL for an Insights Widget that has the specified insight at the top of the feed.

(Optional) Filter Insights

To filter which insights appear in your Mini Insights Widget, request mini_pulse_carousel_widget as the widget_type, then append a query string to the widget URL using the following format. Include at least one insight template name (no maximum limit). For compatible templates, see the Insights Library.
Widget URL with query string
Insights display in their original generation order, not the order you append them. Since templates can appear multiple times and the carousel caps at five insights, repeated templates may prevent other insights from displaying. If a user lacks transaction history for a template, it won’t populate; if no templates can populate, two no-state cards appear instead.

Example API Requests

The following examples are for requesting a Widget URL in the Platform API. Add a Spanish-language widget to a website:
Request a Mini Insights Widget to embed on a mobile app through a WebView.
You can embed multiple instances of the Micro Insights Widget on a website, for example, a widget on the Accounts page and a widget on the Transactions page.
Accounts Page
Transactions Page