I would like to integrate the online experiment into Qualtrics, so that participants don't have to go to a different website to complete the experiment, and I will get all the data in the same file.
Using the instructions on the Lab.js website I've managed to run the study in the Qualtrics interface, but I can't get the results to be saved as Embedded Data.
I have created a text entry question in Qualtrics and entered the following code in the HTML view, which shows the study:
<iframe src="https://MyStudy.com/index.html"
style="width: 960px; min-height: 740px; border: none;"></iframe>
This is what I've managed to put together to catch the output from the online experiment, which I've added as JavaScript to the question:
<script>
// Listen for the study sending data
window.addEventListener('message', (event) => {
const data = event.csv
// Make sure that data is included
if (data) {
Qualtrics.SurveyEngine.setEmbeddedData("data",data);
that.clickNextButton();
}
})
</script>
The study runs via the URL in an iFrame (as you can probably tell from the code), and the study responds to key presses, but the embedded data field doesn't record any responses. I've added _data_ as an embedded data field in the survey flow.
I'm not great with JavaScript, so I'd appreciate any help.
Best answer by James
View original