INFOBefore you can integrate the widget, you must have worked with MX to enable your access to insights.
Integrate on a Website (iFrame)
This shows how to integrate the widget on a website using an iFrame.Step 1
Create an iFrame. Make sure the width and height uses the widget’s recommended dimensions.Example
Step 2
In the iFrame’ssrc, you’ll need to request a widget URL specifying micro_pulse_carousel_widget as the widget_type using the Platform API or SSO API.
The URL you’ll receive is single-use and expires after 10 minutes. You must request a new URL every time the page is rendered.
Example
Step 3
Optionally create listeners for these two application events:- Widget Load – triggered when the widget is loaded.
- Widget Ping – used to keep the widget session alive.
Example
Step 4
Configure event listeners for:- An event for when the user clicks the View all > CTA. When the user clicks this, you’ll consume the info we send to you in the postMessage event and then send the user to the Insights Widget.
- An event for when the user clicks the Learn more CTA. When the user clicks this, you’ll consume additional information from the postMessage event. This will let you send the user to the Insights Widget with the insight the user clicked on at the top of the feed.
Example
SUCCESSCongrats! You’ve integrated the Micro Widget!
Integrate on a Website (Widget Loader)
This shows how to integrate the widget on a website using the widget loader.Step 1
Add the widget loader script to the page. Place this file before any other code related to the widgets. This custom script loads the widgets onto the page. You can load the widget loader from the MX production server or download and store it in your local environment. We update the widget loader when needed, so if you’re caching it on your server, refresh your cached version monthly.Example
Step 2
Add a widget placeholder element. Our widget loader will use this placeholder element to embed an iframe containing the widget. The element must have anid of md-widget.
Example
Step 3
Load the widget into the placeholder element. Create a new instance of theMoneyDesktopWidgetLoader class, which is defined in the widget loader script. When you instantiate MoneyDesktopWidgetLoader, you must pass in an object with at least the required URL parameter (see step 4), and possibly one or more optional parameters.
The widget loader will wait until the page has been loaded, and then load the widget into the placeholder element.
Make sure the widget uses its recommended dimensions.
Example
Step 4
You’ll need to request a widget URL through the Platform API or SSO API and set it in the URL parameter (the example is hardcoded). The URL you’ll receive is single-use and expires after 10 minutes. You must request a new URL every time the page is rendered. You can request a widget URL for the Micro Widget by specifyingmicro_pulse_carousel_widget as the widget_type, using the Platform API or SSO API.
See Example API Requests for different configurations.
Example
Step 5
Optionally create listeners for these two application events:- Widget Load – triggered when the widget is loaded.
- Widget Ping – is used to keep the widget session alive.
Example
Step 6
Configure event listeners for the Micro Widget events:- An event for when the user clicks the View all > CTA. When the user clicks this, you’ll consume the info we send to you in the postMessage event and then send the user to the Insights Widget.
- An event for when the user clicks the Learn more CTA. When the user clicks this, you’ll consume additional information from the postMessage event. This will let you send the user to the Insights Widget with the insight the user clicked on at the top of the feed.
Example
SUCCESSCongrats! You’ve integrated the Micro Widget!
Integrate on a Mobile App
To integrate the widget on a mobile app:- Request
micro_pulse_carousel_widgetas thewidget_type, using the Platform API or SSO API. The URL you’ll receive is single-use and expires after 10 minutes. You must request a new URL every time the page is rendered. See Example API Requests for different configurations. - Load the URL received from the previous request into a WebView.
- See Events in Mobile WebViews.
- Capture and parse a URL for the widget load and widget ping application events.
- Capture and parse two URLs, relating to the Micro Widget events:
- A URL for when the user clicks the View all > CTA. When the user clicks this, you’ll 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 clicks the Learn more CTA. When the user clicks this, you’ll consume additional information from the URL. This will let you send the user to the Insights Widget with the insight the user clicked on at the top of the feed.
SUCCESSCongrats! You’ve integrated the Micro Widget!
Move Insight to Top of Feed
This guide shows you how to move an insight to the top of the feed in the Insights Widget. You’ll want to use this if you’re also using the Mini or Micro Widget. This is so users can select View More above an insight in the Mini Widget, which sends them to the full feed, then see that insight at the top. To request an Insights Widget with a specified insight displayed at the top:- Request the Insights Widget with the
insight_guidconfiguration, as shown in the examples. Set the value for theinsight_guidto the vale of thebeat_guidyou received from the Mini Widget postmessage UI event. - The response from this Insights Widget request will contain the URL for an Insights Widget that has the specified insight at the top of the feed.
SSO
Platform
Common Problems
This section covers some common problems with loading a widget URL into a WebView.Minimum Size
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.WKWebView vs. UIWebView (iOS)
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.Default Padding (iOS)
iOS adds padding to its WebViews by default, which can cause problems. To fix this:- Select the WebView providing the widgets in your application and navigate to the size inspector.
- Change the layout margins from “Default” to “Explicit”.
- Update the left and right margins to “0”.
- Ensure the Width is at least 320 pixels.
Default Margin (iOS and Android)
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:- 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.
- Confirm the body and HTML elements have their padding and margin set to “0.”
Viewport (iOS and Android)
For mobile widgets to render, 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
Example API Requests
The following examples are for requesting a Micro Widget URL in the Platform API. Request a widget to embed on a website.microwidget_instance_id to a unique string value for every instance. This lets us collect data for each instance of the widget. For example, one instance that displays on the accounts page could be set as follows…
Accept-Language header and setting it to es.
PostMessage UI Events
When certain events trigger in our UI, we send you a postMessage UI event. These events have the information you need to take action in your codebase in response to the event. It’s your responsibility to add a listener to capture the properties of these triggered events and also handle what happens next. If integrating on mobile through a WebView, an alternative to standard postMessage UI events is required. See Events in Mobile WebViews for more information. PostMessage UI events from MX, as seen in the previous example, have the following properties:- The
mxfield that lets you filter out postMessage UI events coming from MX. - The
typefield that identifies what the event represents at a high level. - The
metadataobject field that has information related to thetype.
Example
Events in Mobile WebViews
Because of the technical limitations of WebView-based widget implementations, an alternative to standard postMessages is required. 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 them to build the necessary logic for coordinating application events. When requesting a widget URL using the SSO API or Platform API, you must include theis_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, don’t set the is_mobile_webview flag, or set it to false.
For the Micro 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.
DANGERNot capturing this URL can cause the app to break.
beat_guid, beat_template, and user_guid.
Application Events
Widget Load
This event triggers when the widget loads.Widget Ping
This event keeps the widget session alive.Micro Widget Events
The Micro Widget has two postMessage events. One postMessage event triggers when the end user clicks the View all CTA in the Micro Widget’s header. If you have the header enabled, you must add a listener for this postMessage that sends the user to the Insights Widget. This event will look like the following.Example
metadata includes a beat_guid. You’ll 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.
This event will look like the following.
Example
Widget Loader Configurations
This section is for integrating a widget on desktop using the Widget Loader. It shows the parameters you’ll use to set things like the widget’s height and width, additional configurations that let you set configurations for specific widgets, and also has the following sections to further help your integration:- Create a Loading Message
- Keeping a Session Alive and Logging Out
- Loading Multiple Widgets
- Loading Widgets at Different Times
- Master Widget Deep Linking
Widget Loader Parameters
When you instantiateMoneyDesktopWidgetLoader, you must pass in an object with at least the required URL parameter, and any of the following optional parameters.
| Parameter | Required? | Default Value | Description |
|---|---|---|---|
autoload | No | true | Determines if the widget loads automatically. See Loading Widgets at Different Times. |
config | No | This contains an object in which you can set configurations. Some of these configurations are for specific widgets. While setting configurations this way is supported, the most current way of setting these configurations is through the widget URL request. See Config Parameter for more info. | |
height | No | 600 | The widget’s height, in pixels or a percentage. |
id | No | 'md-widget' | Tells the widget loader what element to place the widget in. See Loading Multiple Widgets. |
width | No | '100%' | The widget’s width, in pixels or a percentage. |
url | Yes | The widget’s URL, received through an SSO API or Platform API request. |
Config Parameter
Theconfig object, as shown in the following example, contains configurations options.
Example
| Configuration Option | Data Type | Description |
|---|---|---|
is_mobile_webview | Boolean | Defaults to false. Renders the widget in a mobile WebView. Executes URL updates in place of the JavaScript event postMessages. |
language | String | Deprecated. See Localize Insights Widgets. |
ui_message_version | Integer | Use this to specify which version of postMessage UI events are triggered. All new implementations must include this option when getting any widget URL and must set it to version 4. Prior versions are deprecated and supported only for existing integrations. |
Create a Loading Message
Any HTML placed inside of the widget placeholder element will be replaced once the widget iframe has loaded. This means you can use the placeholder element’s inner HTML to display a loading message. Since this is just HTML, it can be text, images, or anything you want. The following example adds some loading text that will appear until the widget has loaded.Example
Keeping a Session Alive and Logging Out
MX provides two important functions for the widget loader: ping and logout. The ping function resets the session timer, allowing you to keep the session open as long as needed. The default timeout period is 900 seconds, and ping can be used anywhere in that period to restart the timer. A custom timeout period can be set by contacting MX, but MX recommends using the ping method rather than setting a longer timeout.Loading Multiple Widgets
To load multiple widgets on a single page:- Define multiple placeholder elements, each with a unique CSS
id. - In your JavaScript, create an instance of
MoneyDesktopWidgetLoaderfor each widget. - Connect each loader instance to a placeholder element by setting the
idproperty value as the CSSid.
Example
Loading Widgets at Different Times
By default, widgets load automatically once the web page has loaded. If you’d like to load your widgets manually you can use the autoload option by setting autoload to false when instantiatingMoneyDesktopWidgetLoader.
When you’re ready to load a widget, call the load method on the instance of MoneyDesktopWidgetLoader with the URL.
Here’s an example of loading the Accounts Widget on page load, then loading the Transactions Widget when a button is selected.
Example

