Skip to main content
You can embed a Self-Service Analytics component using JavaScript. The following components can be embedded:
  • dashboards, lite dashboards
  • visual authoring experience
  • source editor
When components are embedded, the way in which users can interact with them is determined by settings established in their user account. See Embedded Self-Service Analytics Component Controls. Complete examples of JavaScript code that initializes and authorizes the EmbedManager class are provided in Embedded JavaScript Examples. Follow these steps:

Step 1. Verify the Prerequisites Have Been Met

Verify that the embedded dashboard prerequisites have been met. See Embedded Component Prerequisites.

Step 2. Make the Embed Manager Available to Your Application

To make the Self-Service Analytics’s embed manager available to your application, include this script in your HTML:
where <samplecomposerurl> is the URL of your Self-Service Analytics instance. After this script is run, the initComposerEmbedManager function is available globally in window.

Step 3. Initialize and Authorize the Embed Manager

Use the window.initComposerEmbedManager function to initialize and authorize the embed manager. This can be done using the following configuration properties. Note that the token you supply must be obtained beforehand using the Trusted Access API, usually in backend code that supports your HTML. The getToken property is a method that returns a token from Trusted Access prior to token expiration. Here is an example:
After the initComposerEmbedManager function is called, it returns a promise that resolves an instance of the EmbedManager class. The objects, methods, properties, and embedded events provided with the EmbedManager class can be used in your HTML.

Step 4. Create and Render a Component in Your Application

After the EmbedManager class has been initialized and authorized, you can use its methods to embed a Self-Service Analytics component in your application and set various properties for that component. In addition, you can use embedded events to control component behavior when specific events occur. Other EmbedManager methods can be used to modify, refresh, and remove components in your application. Complete descriptions of the supported EmbedManager methods and properties are provided in EmbedManager Methods, Embedded Dashboard Properties and Objects, and Embedded Visual Authoring Properties and Objects. Supported embedded events are described in Embedded Events. The following simple example creates and renders an embedded dashboard:
The following simple example creates and renders an embedded lite dashboard:
Optionally, return dashboards to your users that match a filter string you have defined (partial example):
Supported operators include IN, NOT, !=, <>, AND, and OR.

Embedded JavaScript Examples

This section provides JavaScript examples that use methods, properties, and embedded events of the EmbedManager class to embed, refresh, reauthenticate, or remove Self-Service Analytics components from your application.

Embedded Dashboard JavaScript Example

The following JavaScript example uses methods, properties, and embedded events of the EmbedManager class to embed, refresh, reauthenticate, and remove a dashboard.
  • The createOrGetEmbedManager asynchronous function provides an initial access token using Trusted Access.
  • The addDashboard asynchronous function embeds a dashboard in the application. It uses the dashboard ID as input so it knows which dashboard to embed. It also specifies some properties for the dashboard.
  • The clearDashboard asynchronous function removes a dashboard from the application. It uses the dashboard ID as input so it knows which dashboard to remove.
  • The refreshDashboard asynchronous function refreshes the authorization token for the embedded dashboard using Trusted Access.
  • The application asynchronous function at the end combines the use of all the previous functions and uses embedded events to trigger some of them.
The Self-Service Analytics EmbedManager class must be made available to your HTML application prior to using this sample in your application. See Embed Components Using JavaScript and Trusted Access.
Self-Service Analytics provides a componentInstanceId provides a as part of event details for dashboard, source, and visual events.

Embedded Visual Authoring JavaScript Example

The following JavaScript example uses methods, properties, and embedded events of the EmbedManager class to embed a visual authoring instance.
The Self-Service Analytics EmbedManager class must be made available to your HTML application prior to using this sample in your application. See Embed Components Using JavaScript and Trusted Access.
Self-Service Analytics provides a componentInstanceId provides a as part of event details for dashboard, source, and visual events.