Search code examples
javascriptqualtrics

Retrieve the reaction time in Qualtrics


I wrote the following script to measure the respondent's reaction time for each question. My question is how can I retrieve the reaction time?

Qualtrics.SurveyEngine.addOnload(function(){

	var starttime = new Date().getTime();

	var that = this;

	this.hideNextButton();

	this.questionclick = function(event,element){

		if (element.type == 'radio') {
			var endtime = new Date().getTime();
			var reactiontime = endtime - starttime;
			document.getElementById("QR~"+this.questionID).value = document.getElementById("QR~"+this.questionID).value + "X" + reactiontime + ",";
		}
	that.clickNextButton();
	}

});


Solution

  • You can save reaction time to an embedded data variable. Define reactiontime as an embedded data variable in the survey flow prior to the question block. Then:

    Qualtrics.SurveyEngine.addOnReady(function(){
        var starttime = new Date().getTime();
        $('NextButton').hide();
    
        this.questionclick = function(event,element){
            if (element.type == 'radio') {
                var endtime = new Date().getTime();
                var reactiontime = endtime - starttime;
                Qualtrics.SurveyEngine.setEmbeddedData('reactiontime', reactiontime);
                $('NextButton').click();           
            }
        }
    
    });