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?&autoplay=1&disablekb=1&modestbranding=1&controls=0&showinfo=0&rel=0&" 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();
}
});
});
To activate key stroke submission, paste the javascript code, above, into the JavaScript field of your question. The numbers74 and 75 are the JavaScript key code numbers for the J and K keys. To use different keys, you can find the appropriate numeric codes at this site: http://css-tricks.com/snippets/javascript/javascript-keycodes/
To record reaction time (to the nearest centi-second), include a Qualtrics timer question on the page.
Auto-advance after multiple-choice mouse-click:
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:
An embedded data field for each Loop & Merge block we want to record
A unique identified for each loop in the Loop and Merge. We typically just use a number (though in our implementation this gets hairy if we have large numbers of items)
Some special javascript, including a call using one of Qualtrics' methods
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")
"To access embedded data at any time using javascript: simply set a variable to be equal to the piped text required to access to embedded data in survey questions (as a string).
For example,
var myData = "{e://Field/myEmbeddedData}"; /*(don't forget the quotes!)*/
To write a new value to an embedded data field, use the call Qualtrics.SurveyEngine.setEmbeddedData("fieldName", newvalue);
For example, to change the value of the embedded data field myEmbeddedData to be equal to 10, write
Qualtrics.SurveyEngine.setEmbeddedData('myEmbeddedData', 10);
"
Here's how to get images--that change from trial to trial within a Qualtrics loop--into the loop-and-merge block.
The first task is to get each image onto the web. I used the Qualtrics Library for this purpose.
Select the Library tab, then the Graphics Library icon, then Upload a New Graphic, then Choose File.
When a thumbnail of the graphic appears, click it to see the full-sized image.
Right-click the full-sized image, then select Copy Image URL.
Paste each URL into a cell in the loop-end-merge sheet.
Using the the survey question's Piped Text interface, pipe-in the loop-and-merge field containing the image URL.
Using the question's HTML view, locate the loop-and-merge pipe that you entered. As an example, from here on out, let's assume that you piped in Field 1.
Save the question.
Select Normal View, and then select HTML view again (to see updated html).
In the HTML view, replace each instance of ${lm://Field/1} with <img width="700" src="${lm://Field/1}">
Note that you may omit width="700" if you don't want to re-scale the image.
*TML Tips in Qualtrics
Remove the automatic underlining from a hyperlink
<a href="http://www.yahoo.com" style="text-decoration: none">Go to Yahoo</a>