Embedded data with custom javascript | XM Community
Skip to main content
Hi all,



I'm currently trying to record text data with custom javascript. I have hole text that I ask my participant to fill. Once, the participant has finish I want that when he/she clicks on a submit button the text data are recorded.



From what I saw in the Qualtric documentation, there is the possibility to use the addEmbeddedData ( ) function. So what I did is the following:

1) I created an Embedded Data in the Survey Flow with the column 'data', 'rep1', 'rep2', 'rep3', 'rep4', 'rep5', 'rep6', 'rep7', 'rep8', 'rep9', 'rep10' all of String type.

2) To test that my data are actually recorded, I added the below code. When the page load, there is an automatic insertion of some text values in the corresponding columns:



Qualtrics.SurveyEngine.addOnReady(function(){

Qualtrics.SurveyEngine.addEmbeddedData ( 'data' , 'test' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep1' , 'tellement' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep2' , 'fantastique' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep3' , 'genial' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep4' , 'style' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep5' , 'relaxe' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep6' , 'test' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep7' , 'trompette' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep8' , 'force' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep9' , 'fraise' )

Qualtrics.SurveyEngine.addEmbeddedData ( 'rep10' , 'universite' )

});



However, it seems that the data are not recorded. Do you have an idea of what I'm doing wrong?



Thanks for your answer!



D.
Instead of addEmbeddedData, use setEmbeddedData. Make sure you have created all ED in the survey flow before the question where you are using custom code.

https://www.qualtrics.com/community/discussion/comment/21789#Comment_21789I actually feel like this is not a proper solution. I require the use of dynamic generated ED, ie the names are generated based on a Loop&Merge number during survey-taking, and it would be quite helpful this have this data saved at the end of the survey. There is only one work real workaround for this as far as I can figure out - create a text entry question that is populated by JS then hidden with JS or CSS - but even that seems kinds of excessive.


I'm a little unclear on what you want to do. However, I am guessing it's one of two things:

  1. Change embedded data based on some choices. For this, you need to insert your code in the addonPageSubmit are. (See some examples here: https://github.com/tafakkur/QualtricsHub/tree/master/JavaScript%20Files)

  2. You want to use this dynamically populated embedded data in a question or as answer choice. For this, you'll need to have atleast one page break between setting your embedded data and using it. Else, Qualtrics will use the older value.


Hi everyone! I'm also in a similar position. I'm using Qualtrics to record feedback data. However, I also want to record some metadata (

groupId
) around this. I'm passing the metadata through JavaScript according to the documentations mentioned. Below is my HTML code snippet:




I have included this in the base HTML file. Most of the script was mentioned in the documentation. I've only added the
addOnload
method. However, on my server, it says
Uncaught ReferenceError: Qualtrics is not defined
. Isn't the script supposed to define Qualtrics on its own? Could anyone point out what I'm missing here? Thanks!


Leave a Reply