Solved
Qualtrics - Getting data from a behavioral task (BART)
I'm currently trying to get a behavioral task to work with Qualtrics using Javascript. Essentially, the task consists of people pumping a balloon. Each pump brings it closer to popping the balloon, but they get more rewards based on the number of times they pump. They can collect rewards at any time. In total, they repeat pumping balloon and collecting rewards 30 times (30 rounds). I'm interested in how many times they press the pump button in each round.
I was able to find a script online that can be used to display the task in Qualtrics (did not write it myself). I'll add the code to the comments. The only thing that was missing was a way to get Qualtrics to record the data I want. I've looked through forums and found that the following script can be used to get Qualtrics to record data:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
Qualtrics.SurveyEngine.setEmbeddedData( 'embeddedDataVariable', value );
Qualtrics.SurveyEngine.getEmbeddedData( 'embeddedDataVariable');
<!-- end snippet -->
I would also have to set and embedded data variable in the survey flow in Qualtrics. I thought that the best way to do this is to have an embedded data variable representing pumps for each round (e.g., BART1 for pumps in the first round, BART2 for pumps in the second round). The code would be set up to have a conditional (if) statement that would record the number of pumps using the above code if the round # matched the embedded data variable I want to record. E.g.:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
} if (round = 1){
Qualtrics.SurveyEngine.setEmbeddedData("BART1", value);
Qualtrics.SurveyEngine.getEmbeddedData("BART1");
} else if (round = 2){
Qualtrics.SurveyEngine.setEmbeddedData("BART2", value);
Qualtrics.SurveyEngine.getEmbeddedData("BART2");
}
<!-- end snippet -->
I have 2 issues that I've been trying to resolve. First, I'm not sure where in the script I'm supposed to put the two Qualtrics lines of code. I've tried putting it at different points in the script (within the pump button function, collect button function, and the continue button function), but none of them seem to work.
The other issue, which is related to the first, is what variable I should be recording (what variable do I input in the value field of the Qualtrics code). I assume I should be putting either the "pumps" or "pumpmeup" variable depending on where in the script the Qualtrics set and add lines of code are, but if you guys have any other suggestions, let me know.
If any of you can help me out with this, I'd really appreciate it! I'm very much a beginner in Javascript (very little experience), so any help is appreciated.
Best answer by LaurenK
Hey @newtothis! For a question involving this much custom code, we would recommend reaching out to an external consultant! They will best be suited to review your code as needed and provide the appropriate suggestions! :)
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
