Qualtrics Loop & Merge Tips

The Qualtrics Loop & Merge utility is a powerful tool and offers great flexibility when dealing with dynamic content in a survey. I want to show off some use cases ranging from very simple to advanced, which you can adapt for use in research.

Simple looping

Let’s say you want to implement a loop over a set of word pairs inserted into a multiple-choice question’s values, as shown here:

You could do this by making a question for each pair, but the Loop & Merge tool can save you all that work. First you need to add Loop & Merge to a new block:

Then, set up the looping values:

*Note that pasting copied Excel cells into these fields can save you a lot of data entry.

Once you have your word pairs in place, pipe the Loop & Merge data into a question. You can use the piped text tool to accomplish this:

And that’s all there is to it! Examples like this are well-documented by Qualtrics, so lets try a more advanced example.

Looping for a specified duration

Say you wanted a respondent to find an anagram for a set of words in one minute and, after that time has elapsed, move on to a new block in the survey. To accomplish this you can simply use a bit of javascript and an embedded data field.

First, set up a non-Loop & Merge block that will set an embedded data field to the current time – you’d use this field to determine when one minute has elapsed and, subsequently, whether the loop should be broken. Next, create an embedded data field – i.e., ‘start_time’ – within Survey Flow, and leave the value unset:

Add the following javascript to this block:

Qualtrics.SurveyEngine.addOnload(function()
{
	Event.observe($('NextButton'), 'click', function (e) { 
	    Qualtrics.SurveyEngine.setEmbeddedData("start_time", Date.now());
	});
	

});

This code essentially does one thing: it listens for the next button-press and, once clicked, the ‘start_time’ embedded data field is set to the current time. Now you’ll know when the next button is pressed. Ignoring lag, this will infer the time the first anagram in the loop was shown.

Next, set up the looping block (which should be nearly identical to the example above). Within the new block’s Loop & Merge settings, add a set of words – e.g., 300 – to a single column of Loop & Merge data:

embedded_data_anagram

*Note that there is an option to randomize the loop order – in some cases this might be desirable.

Now set up the question to show the word and a text field for the anagram submission:

lm_text

Lastly, check if a full minute has elapsed and, if so, break out of the loop. Add the following Javascript to the block to check the elapsed time:

Qualtrics.SurveyEngine.addOnload(function()
{
 var elapsed = Date.now() - Number("${e://Field/start_time}");
 if (elapsed >= 60000){
 Qualtrics.SurveyEngine.setEmbeddedData("start_time", 0);
 }
});

This should calculate the difference between the current time and the previously set embedded data ‘start_time’ field, as measured in milliseconds – i.e., check if the elapsed value is greater or equal to 60000 (60000/1000 = 60 seconds); if so, set the ‘start_time’ field to zero.

Now all you need to do is add the display logic to break out of the loop. (This can be accomplished by displaying the question only if the ‘start_time’ embedded data is greater than zero.)

display_logic

The result? A respondent will be able to enter anagrams for one minute, before advancing to the next block of the survey.

It’s Easy When You Know How!