How to embed a Qualtrics survey on my website? | XM Community
Question

How to embed a Qualtrics survey on my website?

  • 18 November 2021
  • 1 reply
  • 356 views

How to embed a Qualtrics survey on my website? As I know, iframe and Site Intercept are the options.
My question is, is the iframe way a kind of best practice? Or what's the Qualtrics officially recommended solution to this requirement?
If I use iframe, then how does my website(parent) know if Qualtrics survey(child) has been submitted?
Thank you!


1 reply

Userlevel 4
Badge +18

EthanDong - Qualtrics site intercept is recommended for better management of surveys in different sections of website.
You can still use iframe and pass message to parent from survey(child) itself.
In survey(child) we can have this javascript on the last screen. This will pass the message to parent website.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
jQuery('#NextButton').click(function(){

window.parent.postMessage({'sender': 'Next_pressed', 'msg': 'hey next button is pressed loaded'}, "*");
});
});

In website you can have a receiver to act-on.
window.addEventListener('message', function _data_handler(event) {
   if (event.data.sender == 'Next_pressed') {
//do needful here
    console.log('Main window:', event.data.msg)
   }
   else
    console.log('Some other message')
  });

This may not work with preview link(test link) as it already have two iframes for mobile view.

Leave a Reply