How to measure time a respondent takes to type an input | XM Community
Skip to main content

I have two input textboxes per question, and I'm trying to measure the time it takes them to fill out both textboxes.
I guess I could start a timer for a keydown/keypressed eventListener or even use Qualtric API's questionclick function (if I understood it right), but I'm not sure when to end the timer esp. because there may be some time lapse between the respondent finishing typing and clicking on the next button. Does anyone know how to deal with this?

assign a listener to oninput of the text boxes. Store the time of each input as an array. Keep the first and last.


@ahmedA
hmm how do I refer to the text boxes though? for example, I know the next button is referred to as NextButton, but I'm not sure what to call the text box inputs.
could you show me an example of using oninput on textboxes?


Here's the code:
Qualtrics.SurveyEngine.addOnReady(function () {
    let quest = this;
    let time_arrays = {};
    let all_inputs = quest.questionContainer.querySelectorAll(".InputText");
    all_inputs.forEach((text_box) => {
        time_arraystext_box.id] = ];
        text_box.oninput = function () {
            time_arraysntext_box.id].push(Date.now());
        };
    });
    document.querySelector("#NextButton").onclick = function () {
        Object.keys(time_arrays).forEach((id) => {
            let id_time = time_arraysid].pop() - time_arrays_id].shift();
            Qualtrics.SurveyEngine.setEmbeddedData(id.replaceAll("~", "_") + "_time", id_time);
        });
    };
});

It should work for any question with a text entry box. You'll have to setup embedded variables looking like the image below.
image.png


Leave a Reply