Advanced Qualtrics


A Warning about the Survey Flow Feature

If a participant sees the same block of questions twice while taking a survey, the second time around all of the answers will be pre-filled and the participant will be able to review and update what they answered previously. Only the final set of answers will be included in the logged data.

In Survey Options:

You should probably disable "Save and Continue. Allow respondents to save and continue later." If it's enabled, especially when you're developing your experiment, any changes you make to the experiment won't fully be implemented unless/until you completely finish any previous attempts to run the experiment.

The Official Qualtrics' Javascript Resource

John Henry's Javascript/Qualtrics Page 

A Resource Page by Joseph Williams and Samuel Maldonado

Prolific

Interfacing Qualtrics with Prolific

MTurk

Interfacing Qualtrics with MTurk

General Info about Using MTurk

Using advanced logic for custom validation of responses

See https://www.qualtrics.com/support/survey-platform/survey-module/using-logic/#QuestionLogic

Saving and Exporting Randomized Orders 

Currently on Qualtrics' Data Analysis > Export Data page, you can opt to  Export Viewing Order Data for Randomized Surveys. 

However, this does not work for exporting the viewing order of randomized Loop & Merge tables. To export the Loop & Merge you need to do a few things. Include a text entry question in the loop & Merge block. 

Use Default Choices to pre-populate the text entry field with the current time--including seconds. (You can even opt to include the date with the time, but make sure to include the seconds.) 

Use javascript to hide the question: 


Qualtrics.SurveyEngine.addOnload(function() {

    jQuery("#"+this.questionId).hide();

}); 


Note: It's essential to use javascript, and NOT display logic, to hide the question. If a question is hidden using Display Logic, the (pre-populated) answer won't be saved. 

Later, when analyzing the data, you can reconstruct the order of the randomized loop by looking at the time stamps that show when each row  in the loop & merge table was run.  This basic approach also works for question-order randomization that doesn't involve loop & merge.

Hiding a 'Slider' Handle Until the Participant Touches the Slider 

Qualtrics.SurveyEngine.addOnload(function()

{

/*Place your JavaScript here to run when the page loads*/

var q = jQuery("#"+this.questionId);

q.find(".handle").css('visibility', 'hidden');

q.find(".track").on("click , touchstart", function() {

jQuery(this).find(".handle").css('visibility', 'visible');

});

});

Making the 'Slider' track thicker 

In Look and Feel / Style / Custom CSS, insert the following:

 .Skin .horizontalbar .Slider .track {

height: 30px;

}

.Skin .horizontalbar .Slider .td.BarOuter {

height: 60px;

}

.Skin .horizontalbar .Slider .handle {

height: 50px;

}

Changing the Size and Color of the Numbers in a 'Slider' Question 

In the question's javascript field:

Qualtrics.SurveyEngine.addOnload(function() {

jQuery("#"+this.questionId+" ul.numbers li").css("font-size","larger");

jQuery("#"+this.questionId+" ul.numbers li").css("color","red");

});

Hide All Answer Fields in a Matrix Question (for simply presenting a set of randomly ordered rows of text) 

Qualtrics.SurveyEngine.addOnload(function()

{

this

.getQuestionContainer()

.querySelectorAll("[class^='q-']")

.forEach(button => button.hide());

});

Use javascript to Hide a Question Without Disabling the Questions other Aspects

jQuery("#"+this.questionId).hide();

Incorporating Video 

See Adding Media Using HTML at the following link.

Example: A YouTube video that starts automatically, that the user can't pause or stop, and that does not advertise additional videos at the end:

<iframe  style="pointer-events: none;" src="https://www.youtube.com/embed/noCWtagaDJQ?&amp;autoplay=1&amp;disablekb=1&amp;modestbranding=1&amp;controls=0&amp;showinfo=0&amp;rel=0&amp" frameborder="0"width="560"height="315"></iframe>

*Additional tips on using Javascript with Qualtrics

Documentation for setting up loops in Qualtrics. Note: Qualtics' ability to loop through questions is rudimentary and not very flexible. For flexible looping, you may need to use another software platform.

Qualtrics no longer makes the following information available on its support pages, but it still works as of 2020.

Use Keystrokes to Answer Questions

With this code, participants can answer a question and move to the next page by pressing a key on a keyboard. When combined with a Timing Question, this is an optimal way to run many types of reaction time studies. Click here to see an example.

Note: The script works fine whether it uses addOnload or addOnReady. Also note that that you may need to alter the Choice_ID values to something other than 1 or 2. For the question, select the gear icon, and then "re-code values to see what the actual numerical choice values are. (You need not actually re-code the responses).

Qualtrics.SurveyEngine.addOnload(function()

{

this.hideNextButton();

this.hidePreviousButton();

var that = this;

Event.observe(document, 'keydown', function keydownCallback(e) {

     var choiceID = null;

     switch (e.keyCode) {

     case 74: // 'j' was pressed

          choiceID = 1;

          break;

    case 75: // 'k' was pressed

          choiceID = 2;

          break;

     }

if (choiceID) {

 Event.stopObserving(document, 'keydown', keydownCallback);

 that.setChoiceValue(choiceID, true);

 that.clickNextButton();

 }

});

});

this.hideNextButton();

this.questionclick = function(event,element){

if (element.type == 'radio')

{

this.clickNextButton();

}

}

Tracking the Order of Loops in a Qualtrics Loop & Merge Block (see below)

Submitted by Sam Maldonado on Mon, 04/29/2013 - 17:27

http://sgmaldonado.com/main/tracking-order-qualtrics-loop-merge

"The Qualtrics survey platform is awesome, and has a ton of exciting features, which I plan to write about in the future. One of those features is the Loop & Merge block type.

What is Loop & Merge?

Loop & Merge blocks basically offer you a way to ask the same question multiple times, with variables within the question changing every time it is asked. For instance, in one recent experiment I helped program, we wanted to ask participants to make judgments about several students. We used a loop and merge to set the names, course types, and other information of the students so we could ask about many students using the exact same wording and without having to copy the question over and over again. You can even paste cells directly from an Excel spreadsheet into the Loop & Merge, so using formulas to create appropriate data was a breeze. You can find more information about Loop & Merge blocks on the Qualtrics University.

Loop & Merge is pretty neat, but it has a serious flaw: it doesn't record the order of randomized loops.

Recording Random Loops

So, Loop & Merge blocks have the option to turn on randomization of the loop order, which is great – in our research, it tends to be our default. However, we run into an issue: the order in which loops are presented isn't recorded! This is a problem of course – as any psych student can tell you, ordering effects can be important. So how can we record the ordering of the loops to make sure the order in which we present our materials isn't affecting our results? The answer is threefold:

Items one and two are straightforward: create an embedded data field, and an extra loop & merge field to identify each loop. For this example, our embedded data field will be called "preorder" (for recording the order of a pretest) and we will use the first field of the Loop & Merge as our identifier.

Now, on to the javascript, which I've tried to comment well enough to make each line understandable (in javascript, single line comments begin with "//"). I added it using the "Add Javascript" option available on every question.

  /*Place Your Javascript Below This Line*/

  var questionText = "${lm://Field/1}"; // "${lm://Field/1}" will actually evaluate to 

  //whatever is Field 1 in the current Loop & Merge loop.

  // You can do this with embedded data too, as seen in the next line

  var order = "${e://Field/preorder}"+ questionText; // gets the value of the embedded data

  // field "preorder", concatenates the current loop's identifier to it,

 //and stores that as a variable

  Qualtrics.SurveyEngine.setEmbeddedData('preorder', order); // updates the 

  //embeddeddata field "preorder" to be our order variable, which has the current loop's

  //identifier attached, effectively constructing a string of numbers representing the order

This code is run every time the page containing it is loaded (e.g. on every loop of our Loop & Merge). It takes the order as it currently is, adds the current loop to the order, and then passes that back to the embedded data field so it is stored. Voila! Your survey will now track the order in which items in a Loop & Merge are presented!

Final Thoughts

There are a couple of things worth mentioning. First, the setEmbeddedData method cannot create a new embedded data field, it can only update an existing field. So far, we have not found a way to generate embedded data fields on the fly – it may not be possible at all (but if someone knows, let me know in the comments!).

Secondly, as I mentioned above, this implementation will give you a string of numbers, like "7153264". We decided on this so that our statistical package wouldn't have to deal with delimiters. however, this becomes tricky when you have more items, and it becomes almost impossible to tell whether, say, the substring "21" represents item 2 then item 1, or item 21. It would be easy to add delimiters though; to use the pipe character, |, as a delimiter, you would just modify var order = "${e://Field/preorder}"+ questionText; to be var order ="${e://Field/preorder}"+ "|" + questionText;, and of course you can change the delimiter character to be anything you'd like.

That's it! Your surveys will now record the order of loops, so randomize Loop & Merge without fear!"

How to Access and Write Values to an Embedded Data Field at any Point in the Survey (from Joseph Jay Williams, "Functions and Capacities in Qualtrics")

Here's how to get images--that change from trial to trial within a Qualtrics loop--into the loop-and-merge block. 

Note that you may omit width="700" if you don't want to re-scale the image.

*TML Tips in Qualtrics

                    <a href="http://www.yahoo.com" style="text-decoration: none">Go to Yahoo</a>