Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. READ MORE

Qlik Sense Enterprise SaaS: How to embed a chart in an iFrame

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Damien_V
Support
Support

Qlik Sense Enterprise SaaS: How to embed a chart in an iFrame

Last Update:

Apr 28, 2024 9:50:32 AM

Updated By:

DaveChannon

Created date:

Sep 26, 2019 9:56:23 AM

Please note that due to changes in how browsers handle third-party cookies, you may wish to instead leverage the new qlik-embed framework with OAuth2 for your embedding needs, rather than the guidance in this tutorial.

In Qlik Cloud Services (Qlik Sense Enterprise SaaS), it is possible to get the iFrame HTML code to embed a chart in a webpage by right-clicking that chart and choosing "embed chart".

However, just placing this code on a web page is not sufficient to handle the authentication part.

The information provided in this article provides an example of how this can be achieved. Further customization is likely necessary. For assistance, join our active community in the Integrations and Extensions forum or contact our Consulting Services for an engagement. 

Environments:

  • Qlik Cloud Services April 2019 and later

 

Resolution:

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

 

Steps

  1. Open the Qlik Tenant Management Console
  2. Scroll to Integration Settings
  3. Open Web
  4. Click Create new 
  5. Fill out the form:
    • Name: The name of the integration 
    • Add an origin: The allowed origins for the requests (such as the webserver hosting the integrations)
  6. Click Create to confirm
  7. Open Content Security Policy in the Integrations Settings section 
  8. Click Add
  9. Fill out the form:
    • Name: The name of the integration
    • Origin: The allowed origins for the requests (such as the webserver hosting the integrations)
    • Directive: Choose frame-ancestors
  10. Click Add to confirm
  11. Copy the script provided in this example:

    To handle the authentication and be able to see the chart on an external web page, the parent site needs to do a redirection and let the user authenticate, below is a code example of how to do that.
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <script type="text/javascript">
        const webIntegrationId = "g-yrbnOz9wV5-YnIqYLZMgfAxf_iKg30";
        function login() {
          function isLoggedIn() {
            return fetch("https://yourtenant.eu.qlikcloud.com/api/v1/users/me", {
              method: 'GET',
              mode: 'cors',
              credentials: 'include',
              headers: {
                'Content-Type': 'application/json',
                'qlik-web-integration-id': webIntegrationId,
              },
            }).then(response => {
              return response.status === 200;
            });
          }
          return isLoggedIn().then(loggedIn => {
            if (!loggedIn) {
              // check login
                window.top.location.href = "https://yourtenant.eu.qlikcloud.com/login?qlik-web-integration-id=" + webIntegrationId + "&returnto=" + top.location.href;
              throw new Error('not logged in');
            }
          });
        }
    	login()
      </script>
    </head>
    
    <body style="height:600px;">
    	<iframe
        src="https://yourtenant.eu.qlikcloud.com/single/?appid=9539b869-1c84-4e6d-9129-4c5b031ca88a&obj=WJhPv&opt=ctxmenu,currsel"
        style="border:none;width:100%;height:100%;"></iframe>
    </body>
    
    </html>​


  12. Paste it into a new file using Visual Studio Code and save it with the HTML extension
  13. Replace all mentions of yourtenant in the script with the name of your Qlik Sense SaaS tenant
  14. Copy the Web Integration ID from the Web Integration menu and paste it into the script at:
    const webIntegrationID = "IDGOESHERE";​
  15. Add the link to the Qlik App Object you want to embed in the <iframe> section:
    <iframe>src="linktotheobjecthere"></iframe>
  16.  Save the file and place it where your web server can read it. 

 

 

 

Labels (2)
Comments
NielsvanWingerden
Partner - Contributor
Partner - Contributor

Hi @Damien_V , Hi @Sonja_Bauernfeind 

 I followed the instructions to load an iframe into a online SharePoint page. And this worked, the iframe was shown and all is fine I thought… Only when I disconnect from Qlik SaaS the iframe disappeared and the error “login.qlik.com refused to connect.” appears.

Now I would like to know if it’s possible to embed the iframe with authentication in a online SharePoint environment?

Thanks in advance!
Niels

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @NielsvanWingerden 

In order to handle the authentication and be able to see the chart on an external web page, the parent site needs to do a redirection and let the user authenticate. The code example shows how this could potentially work.

In order to get you the assistance that you need, I would recommend posting about your requirements and what challenges you are facing in our Integration forum

If you, however, require direct assistance on this, our professional services are available to assist you.

All the best,
Sonja 

Damien_V
Support
Support

Hi @NielsvanWingerden 

In theory it should just be a matter of replacing

window.location.href = "https://yourtenant.eu.qlikcloud.com/login?qlik-web-integration-id=" + webIntegrationId + "&returnto=" + location.href;

by

window.top.location.href = "https://yourtenant.eu.qlikcloud.com/login?qlik-web-integration-id=" + webIntegrationId + "&returnto=" + top.location.href;
rva
Partner - Contributor III
Partner - Contributor III

It took me a while to find the new Syntax for handing over parameters to the iframe. Please refer to:

https://help.qlik.com/en-US/sense-developer/February2023/Subsystems/Mashups/Content/Sense_Mashups/Si...

 

This is different from Qlik Sense Enterprise on Windows. The parameter looks like

 

https://yourtenant.eu.qlikcloud.com/single/?appid=55628380-6eac-4a86-a63b-2396021b48d2&sheet=8462272...select=Country,Germany,Austria&select=CategoryName,Beverages

Ken_T
Specialist
Specialist

could you do another version of this --- but use a SharePoint page as the example?

mickael_b2boost
Partner - Contributor II
Partner - Contributor II

We are losing the some context menu and object resizing features when using this feature.  Any tip on how to keep them while using i-frames ?

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @mickael_b2boost 

I recommend posting about your specific requirement and challenge in our Integration forum, where other active users and our support agents can review it for you.

All the best,
Sonja 

 

raviadiwal23
Contributor
Contributor

Can we add custom images, custom objects like radio buttons in iframes

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @raviadiwal23 

Please post your question in the Integration and API forum.

All the best,
Sonja 

Version history
Last update:
‎2024-04-28 09:50 AM
Updated by: