How to export embedded data stored with JS? | XM Community
Solved

How to export embedded data stored with JS?

  • 2 July 2020
  • 4 replies
  • 122 views

Badge

I'm using JS to store embedded data (code below). It seems to work, as I am able to embed the data in the survey. However, when I export the survey responses the embedded data variable is empty. I created a variable in the survey flow before the JS code was applied (attached as an image), but it still doesn't work. Any idea what I'm doing wrong?
Here is the code:

Qualtrics.SurveyEngine.addOnload(function()
{
jQuery('.QuestionOuter').css('display','none')
var firstName = "${e://Field/firstName}";
});
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('input[type="checkbox"]').prop('checked',true);
var qid= this.questionId;
Qualtrics.SurveyEngine.setEmbeddedData('firstName',String(jQuery('#'+qid).find('.Selection').eq(0).text()));
jQuery('#NextButton').click();
});

Here is how I created the embedded data variable:
Screen Shot 2020-07-01 at 8.43.42 PM.png

icon

Best answer by rondev 2 July 2020, 21:24

View original

4 replies

Badge

Strange - looks like it wasn't working when I used qualtrics' generated responses. However, when I responded myself it did record the randomization.

Userlevel 7
Badge +22

https://www.qualtrics.com/community/discussion/comment/27472#Comment_27472Okay, so java script does not work when generating test responses.

Userlevel 5
Badge +4

The script doesn't have any issue LOB , if you want to check the embedded data value in the middle of testing/in the link you can check in console, use the below code to check if the correct data is getting stored in embedded data.
Qualtrics.SurveyEngine.getEmbeddedData('firstName')
image.png

So there is no way that I can record the embeddedData from a JS code with test responses? I would need to do that to test if my JS code works, e.g. if it randomizes correctly. I understand that I can use the console and that I could enter my own responses (then it is recorded), or test the JS separately and independent from Qualtrics, but this is not what I need. Any ideas?

Leave a Reply