Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Embedded data with custom javascript

dodi
dodi GenevaCommunity Member Qubie ✭

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.

Answers

  • rondev
    rondev Community Member Wizard ✭✭✭✭✭

    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.

  • samly
    samly PhiladelphiaCommunity Member, Qualtrics Brand Admin Qubie ✭

    I 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.

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭
    edited November 2020

    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.