Recording and tracking responses in ranking questions | XM Community
Skip to main content

Hello everyone,
I'm using ranking questions where I ask participants to rank 5-6 objects.
Currently, I'm using the drag & drop version, but don't mind changing to a different one if it would make things easier.
I'm trying to do 2 things:

  1. Record the initial order for the participant (I'm using randomization), to see how much he changed the order.

  2. Track and record the worker movements of items, that is, if he moved the item that was presented first (even better to have its title) to the third place, I'd like to record that and examine afterward in my analysis.

I'd assume that the tracking would be done somehow with the JS script, looking in the forum I've found this bit of code:
Qualtrics.SurveyEngine.addOnload(function()
{
 jQuery('#SOMEID').click(function(event) {
  Qualtrics.SurveyEngine.setEmbeddedData("click", "1");
 });
});
But that one would work for clicking a link, what could I use for tracking the order?

HI Gelo,

here is some javascript that might help.
first, we store the original order
second, we count the number of mouse down events
third, we store the ranked order of items/statements when the respondent clicks the next button

you need three embedded data fields

originalOrder
submittedOrder
mouseDownCounter

then you add the below javaScript to the drag'n'drop ranking question

Qualtrics.SurveyEngine.addOnload(function()
{
let liOriginal = document.getElementsByTagName('li')
let originalOrder = new Array
for(let i=0;i originalOrder.push(liOriginal[i].innerText)
}
   Qualtrics.SurveyEngine.setEmbeddedData("originalOrder", originalOrder.join(','));

});

Qualtrics.SurveyEngine.addOnReady(function()
{
let n = Number("${e://Field/mouseDownCounter}")
document.addEventListener('mousedown', function(){
let clickedButton = event.srcElement.id
if(clickedButton != "NextButton"){
n = n+1;
Qualtrics.SurveyEngine.setEmbeddedData("mouseDownCounter", n);
}
});

});
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
let liSubmitted = document.getElementsByTagName('li')
let submittedOrder = new Array
let cleanedInnerText
for(let i=0;i
cleanedInnerText = liSubmittedei].getElementsByClassName('LabelWrapper')'0].innerText

submittedOrder.push(cleanedInnerText)
}

Qualtrics.SurveyEngine.setEmbeddedData("submittedOrder", submittedOrder.join(','));
});

I hope this helps. There is one caveat though: the mouse event will also count if the respondent picks the item and releases it without moving it

Best regards
Rudi





Leave a Reply