How to redirect participants to a new link and have them come back to Qualtrics once they're done | XM Community
Question

How to redirect participants to a new link and have them come back to Qualtrics once they're done

  • 26 December 2020
  • 4 replies
  • 318 views

Hi all,
I am trying to integrate different platforms for a study that will consist of different parts, each of them build in different platforms (psytoolkit and Neurotask) and/or with different URLs. One option I have found to do this, is embedding the experiments in my qualtrics survey the way they propose in the lab.js website Working with Qualtrics — lab.js 20.1.1 documentation. However, when following these steps to integrate my psytoolkit experiments, for example, I am encountering three problems:

  • First, when the experiment finishes it gets stuck on the last screen.

  • Secondly, I don't know how to embed the data from the experiment into Qualtrics. In the link I shared from lab.js, they use this code:

const page = this
page.hideNextButton()

// Listen for the study sending data
window.addEventListener('message', function _labjs_data_handler(event) {
// Make sure that the event is from lab.js, then ...
if (event.data.type === 'labjs.data') {
// ... extract the JSON data lab.js is sending.
const data = event.data.json

// ... save data and submit page
Qualtrics.SurveyEngine.setEmbeddedData('labjs-data', data)
window.removeEventListener('message', _labjs_data_handler)
page.clickNextButton()
}
})
And therefore, the part where they embed the data is:
Qualtrics.SurveyEngine.setEmbeddedData('labjs-data', data)
But do you have any idea of how that would work for a different platform that is not labjs, like psytoolkit or neurotask? Do I just change the 'labjs-data' to a custom name that I give? Or it should be something specific?

  • Thirdly, when using this method, the screen of the experiment gets 'cut' and the experiment is embedded in a 'square' but it would be nice if it would fit better, or full screen... Do you know if that's possible?

If you know of any other way of embedding links into Qualtrics (in a way that they can then continue with the survey in Qualtrics) and also the data from the experiments (so that the participants' IDs are linked over platforms), please let me know!
Best,
Marina


4 replies

Userlevel 7
Badge +27

First, when the experiment finishes it gets stuck on the last screen.

If you've added the JS code shown, that would indicate that the message event isn't getting fired, and therefore, the next button doesn't get clicked. It would also mean the experiment data isn't populated in Qualtrics.
But do you have any idea of how that would work for a different platform that is not labjs, like psytoolkit or neurotask?

For the same approach to work with other platforms they would have had to implement a "webworker" exactly the same way as labjs. That is highly unlikely.
Thirdly, when using this method, the screen of the experiment gets 'cut' and the experiment is embedded in a 'square' but it would be nice if it would fit better, or full screen... Do you know if that's possible?

It appears that way because it is in an iframe. The only way to have it full screen would be to execute it in browser window. It is possible to integrate with other systems that way using Save & Continue. However, the integration (returning to Qualtrics and retrieving the data) is completely different, and the other platform(s) have to be set-up to support it.

Userlevel 7
Badge +21

I have no experience with Neurotask, so I can't comment on it. The answers below are therefore based on some work that I have done with Labs.js and PsychToolkit.
First: The reason why your studies are getting stuck at the end screen is that you are not providing a way to move forward. In Labs.js, they generate this custom event, which signals to Qualtrics to move to the next page. Line 5 starts the detection and line 14, moves people to the next page. Since, this isn't happening in PsychToolkit, there is no moving forward. I recommend creating a button at the end with the

onclick 
attribute set to
clickNextButton
. When you run the demos on the PsychToolkit site, you'll see that they have a button to show data, something like that.
Second: It depends on the data type that is being created. If the data generated is a string or number, or an array then you can just change the names and it will work. But if it an object, you'll need to first convert it into a string and then store it. Otherwise, you'll just get the text Object as the data. 
Third: The screen is getting cut/scroll bars are appearing because you haven't configured the height/width of your
iframe 
accordingly. If you look at the HTML that labs.js asks you to use as your question in Qualtrics, in the first or the second line, you'll see something like
height=??px
or
min-height=??px
Change these to avoid the scroll bars/screen cuts. Fullscreen is also possible, and you can simply add a button for it. Take a look here to see how to get it done.
Fourth: If you aren't able to make it work properly in Qualtrics. You can send them to the other page while passing the survey
responseID
(stored in
${e://Field/ResponseID}
) in your URL, which you can extract and store at the destination. You'll have to see the documentation of the destination to get an idea about adding parameters to the URL. For a demo, preview a survey, open the console and type the following command over there
document.URL.split(/\\?|\\&/gm)
you'll see that your URL has three parts, the first is the base URL, the second your channel and the third the survey version. Usually it by adding stuff after a
?
but the destination platform may have its own requirements.  

Thank you for your help.

Regarding the first point, how can I make that button at the end? The thing is that in Psytoolkit you need to embed the experiment into a survey and maybe that's part of the problem...? So should I make the button inside the Psytoolkit experiment script, or maybe something in the survey options in Psytoolkit? I attach to you the 3 html files have for the experiments... Maybe that helps.
Secondly, can you see in these files I attached what type of data is being created? I don't know how to identify that...
Thirdly, I have tried to play around a bit with the measures in the iframe but if I don't get the scroll bars, then the iframe in which I have embedded the experiment gets too big and participants need to use the general scrollbar of the website to see it all. This thing that you suggested to have a 'full screen button', where should I implement this code? In Qualtrics or in the Psytoolkit experiment?
Fourthly, do you know if there is there a way that this ID I have in the URL becomes the same ID that participants introduce from their Prolific account?

Assets.rar
{"embed-error": true}

Userlevel 7
Badge +21

In the files you have attached the variable is called

outputdata
. It is a string, so you can can directly store that as an embedded data.
As for the others, you can easily find answers to them on the internet.

Leave a Reply