Skip to main content
Once you’ve decided how best to engage your audience, integrate your Insights Widget. This guide explains how to integrate the Insights Widget, Mini Insights Widget, and Micro Insights Widget on a website using an iFrame or on a mobile app. The examples in this guide use Platform API-only fields. If you’re using the Nexus API, use the SSO API fields instead.
If you integrated using the Widget Loader, see 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 widget requires these whitelisted attributes: 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 set to true in your request to access WebView event messages.See Example API Requests for different configurations.
2

Load the URL

Load the URL 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 their information to build the 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

Common problems with loading a widget URL into a WebView:
Embedding our mobile widgets in a WebView requires a device width of at least 320 pixels. Depending on the WebView implementation, smaller devices may not get the full width, causing 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. See Apple’s developer documentation for UIWebView and WKWebView.
By default, iOS adds padding to WebViews, which can cause problems.To fix this:
  1. Select the WebView that provides the widgets in your app and open 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.
In both Android and iOS WebViews, most browsers apply a default margin (set in the user agent stylesheet) to the body element of the HTML page that loads the widget. This margin reduces the containing element’s available width, which causes problems.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 screen, so pages render at the viewport size and then shrink to fit the screen. This helps with pages that aren’t optimized for mobile, but mobile-optimized pages (like the mobile widgets) use the viewport meta tag to ensure they render 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 selected insight to the top of the Insights Widget. To show a specific insight at the top of the Insights Widget:
1

Request a Widget URL

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

Use the URL

The response contains a URL for an Insights Widget with the specified insight at the top of the feed.

Localize the Insights Widgets

Pass your desired language in the Accept-Language header when you call the Request Widget URL endpoint. Widgets default to en-US and support en-CA, en-US, es, fr, and fr-CA.

(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

These examples request 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 Micro Insights Widget instances on a website, for example, one on the Accounts page and one on the Transactions page.
Accounts Page
Transactions Page