Embedded survey - is there a way to detect end of survey? | XM Community
Solved

Embedded survey - is there a way to detect end of survey?

  • 5 February 2021
  • 3 replies
  • 286 views

Hi, I am using iframe to embed a qualtrics survey into my website, which works well. Now I want to show a button on my website only after users have finished the survey. I wonder whether it is possible for my website to detect the user has finished the survey.

icon

Best answer by ahmedA 6 February 2021, 00:29

View original

3 replies

Userlevel 7
Badge +21

If you inspect the end of survey in Qualtrics, I think there is a class/id called "EndOfSurvey". However, the simplest way is to just customize your end of survey with an invisible div like:

 

Then you can detect this and trigger the required response.

Hi ahmedA, thank you for your quick reply. By saying "detect this", do you mean using "getElementByID"? I tried to use this function, but because of the Same-origin policy, chrome doesn't allow my page (parent) to visit the content within iframe (child).

Userlevel 7
Badge +21

Okay. the iframe issue.
You can probably post a message to the parent window. Something like:

parent.postMessage("End of Survey", "https://yourwebsite.com");

You can add an event listener to your JS:
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
    if(event.data.includes("End of Survey")){
        // You stuff here
    }
}
See here and here for more details.

Leave a Reply