Integrate the Micro Widget
This guide shows you how to integrate the Micro Widget on a website using an iFrame, on a website using the Widget Loader, or on a mobile app.
For information on widget behavior, reference the Widget Overview.
Before you can integrate the widget, you must have worked with MX to enable your access to insights.
For this guide, you'll either use the Platform API or SSO API. The API you use depends on what you have purchased and have enabled. If you have the Nexus API enabled, you'll use the SSO API.
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.
Step 2
In the iFrame's src, 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.
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.
See Postmessage UI Events for more info.
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.
See Postmessage UI Events for general info on our postMessage events.
Step 2
In the iFrame's src, 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.
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.
See Postmessage UI Events for more info.
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.
See Postmessage UI Events for general info on our postMessage events.
Congrats! 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.
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 an id of md-widget.
Step 3
Load the widget into the placeholder element.
Create a new instance of the MoneyDesktopWidgetLoader 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.
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 specifying micro_pulse_carousel_widget as the widget_type, using the Platform API or SSO API.
See Example API Requests for different configurations.