I am a total Qubie, new to Qualtrics and JS but eager to learn. I am trying to create a survey to measure cognitive load by recording the response time for each question on a 60 question survey. I know the survey platform can do this with the Timing question, but that would require each item to appear on a separate page, which I would like to avoid. My goal is to record a timestamp of the time the page loaded ("PageLoad") and the last click/response ("AnswerTime") for each multiple choice question in a block of 15 questions, and then calculate the total response time ("ResponseTime") by subtracting the time the page loaded from the time each question was answered. I've cobbled together the code below and added each variable to the survey flow as embedded data, but when I export the data I am not getting any information in the cells for the new variables. I've been working in a sample survey by generating responses and adding a few manual responses using a survey link, but no luck so far. Any advice or help the community can offer would be super helpful!
Thanks!
__
JavaScript for question 5:
```
Qualtrics.SurveyEngine.addOnload(function()
{
var PageLoad = new Date.now();
Qualtrics.SurveyEngine.setEmbeddedData('PageLoad_QID5', PageLoad);
this.questionclick = function(event,element){
if (element.type == 'radio');
var AnswerTime = new Date.now();
Qualtrics.SurveyEngine.setEmbeddedData('AnswerTime_QID5', AnswerTime)};
var ResponseTime = (AnswerTime-PageLoad)/1000;
Qualtrics.SurveyEngine.setEmbeddedData('ResponseTime_QID5', ResponseTime);
});
```
__
Image of JavaScript for question 5:
!
__
Embedded variables in survey flow:
!
Best answer by MeganMarie
View original