Sometimes you need to make sure participants understand something in your study, so you include a question with validation--a question that only advances if the participant got it right.
But it would be nice to know how many times each participant attempted the question.
Qualtrics does not currently (Aug 2022) offer an out-of-the-box solution.
This JavaScript collects saves the number of times the "next" button was clicked on a specific page.
In this particular example, you need to first create the embedded field, "cc_attempts" in your survey flow and set it equal to zero.
Qualtrics.SurveyEngine.addOnload(function()
{ /*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/* Get variable from Qualtrics embedded field and parse (convert) it into a number*/
var attempts = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("cc_attempts"));
/* When the next button is clicked, count & save into the embedded field */
jQuery('#NextButton').on('click', function() {
attempts = attempts + 1;
Qualtrics.SurveyEngine.setEmbeddedData('cc_attempts', attempts);
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
});
To learn more about the Qualtrics methods, go to: https://www.qualtrics.com/wp-content/uploads/2013/05/Qualtrics-Question-API.pdf