Hello! I need to track the amount of time a participant spends on each question, but the questions have to be randomized for my experiment. I know that randomizing questions breaks the functionality of the timing question, so I was wondering if there’s any way to code the time tracking for each question using javascript? Thanks!
How do I add timing questions to randomized block?
![](https://uploads-us-west-2.insided.com/qualtrics-us/attachment/a7748079-2cec-4fbe-b709-639d74a0af64.png)
I’m randomizing show 3 out of 4 question in my pool so I make 3 timing questions. Place them crisscrossing with each other & show 2 questions per page to make a pair. So I will have 3 page submit time for 1st, 2nd and 3rd question.
Let me know if this helps.
You can use JS to time each question and save it in an embedded data field. For example:
Qualtrics.SurveyEngine.addOnReady(function() {
var start = Date.now();
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("Q1ms",Date.now()-start);
});
});
hello,
You can use JS to time each question and save it in an embedded data field. For example:
Qualtrics.SurveyEngine.addOnReady(function() {
var start = Date.now();
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("Q1ms",Date.now()-start);
});
});
TomG, could you please specify “ an embeedingd data field”, how can I find this entrance and put the js code in it?
hello,
You can use JS to time each question and save it in an embedded data field. For example:
Qualtrics.SurveyEngine.addOnReady(function() {
var start = Date.now();
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("Q1ms",Date.now()-start);
});
});
TomG, could you please specify “ an embeedingd data field”, how can I find this entrance and put the js code in it?
In your survey flow, before your randomized block, create an embedded data field to capture the time in milliseconds for each question (Q1ms, Q2ms, etc.).
Add the JS above to each question you want to time, and change “Q1ms” to the appropriate name.
hello,
You can use JS to time each question and save it in an embedded data field. For example:
Qualtrics.SurveyEngine.addOnReady(function() {
var start = Date.now();
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("Q1ms",Date.now()-start);
});
});
TomG, could you please specify “ an embeedingd data field”, how can I find this entrance and put the js code in it?
In your survey flow, before your randomized block, create an embedded data field to capture the time in milliseconds for each question (Q1ms, Q2ms, etc.).
Add the JS above to each question you want to time, and change “Q1ms” to the appropriate name.
TomG, I’m finding your code is working well for me too (I had a very similar application as the original one for this thread and thank you!).
However, in my case I need to create a survey where I am drawing on a randomized selection of 100 questions from a total possible pool of 1,700 questions.
What I’m trying to discern is if I can avoid having to manually override that ID value 1,699 times to specifically name the question (as in “Q1ms,” “Q5ms,” etc.) or if there’s some other way to express that embedded data referent in a way where the JS code can automatically populate it (something like: “this question number” + “ms” ?).
You could use the the question id (i.e., QID1):
Qualtrics.SurveyEngine.setEmbeddedData(this.questionId+"ms",Date.now()-start);
However, you would need to define all of them in the survey flow to capture them in your response data.
You could use the the question id (i.e., QID1):
Qualtrics.SurveyEngine.setEmbeddedData(this.questionId+"ms",Date.now()-start);
However, you would need to define all of them in the survey flow to capture them in your response data.
Thanks very much! I’ll try this out.
![First Comment Badge](https://uploads-us-west-2.insided.com/qualtrics-us/attachment/5b2389c9-3d88-42d0-9ae1-5d222993b788_thumb.png)
hello,
You can use JS to time each question and save it in an embedded data field. For example:
Qualtrics.SurveyEngine.addOnReady(function() {
var start = Date.now();
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
Qualtrics.SurveyEngine.setEmbeddedData("Q1ms",Date.now()-start);
});
});
TomG, could you please specify “ an embeedingd data field”, how can I find this entrance and put the js code in it?
In your survey flow, before your randomized block, create an embedded data field to capture the time in milliseconds for each question (Q1ms, Q2ms, etc.).
Add the JS above to each question you want to time, and change “Q1ms” to the appropriate name.
In the embedded data field in survey flow, would I select Q_TotalDuration and then add the JS above to each question?
![First Comment Badge](https://uploads-us-west-2.insided.com/qualtrics-us/attachment/5b2389c9-3d88-42d0-9ae1-5d222993b788_thumb.png)
Thank you very much, Tom. I understand a bit better now. I’m new to Qualtrics, so I’ve got a bit of learning to do.
Thanks to your explanation in this thread, I understand I have to add an embedded data item in survey flow and use the code you provided above for each question. Another question I have is how to embed the code using the embedded data option. I’m not quite which option to choose as there are so many to choose from:
![](https://uploads-us-west-2.insided.com/qualtrics-us/attachment/d0fa18b4-4a6b-48ff-8a50-1510f292e370.png)
Do I select from the list of options in “Survey Metadata”? There are many options there. Or, do I add the code into the “Set a Value Now” option?
Thank you!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.