A really, really cool feature of Qualtrics that is not well-documented is its web service. If you’re not familiar with Qualtrics web service, it basically allows you to bring in dynamic content from an external website. For example, names, prices, etc. An example of this is Qualtrics’ own random number generator: http://reporting.qualtrics.com/projects/randomNumGen.php. It creates random values that you can then insert into embedded data fields for use in your survey instrument.
Creating a Qualtrics web service is actually more straight-forward than it appeared to me initially. If you only need one number, this is all you need to output in your webpage:
If you need to serve values for multiple variables, you can use an amersand to separate them:
To generate a dynamic file, you can use PHP. Most web hosting providers support PHP, particularly if they run WordPress on their servers. In order for a file to be a php file, all you have to do is add “.php” to the end of the file name. Then, you would add your PHP code to the file. You can make it in any text editor. Here is an example of a PHP file that randomly assigns one of six numbers to a variable that matches up with a given embedded data:
$numbers = array("75","202","43,309","498","595","69,230"); shuffle($numbers);<div class="indented"> echo "numb1=" . $numbers . "&"; echo "numb2=" . $numbers . "&"; echo "numb3=" . $numbers . "&"; echo "numb4=" . $numbers . "&"; echo "numb5=" . $numbers . "&"; echo "numb6=" . $numbers;
You can see that I’ve created an array of numbers, called “$numbers,” I’ve “shuffled” the order of the numbers, and then I use the echo command to output the variable name, which is static text, the value, which is pulled from my $numbers variable, and an ampersand in between each variable.
Here is the output:
You can try it out for yourself at this address: http://webservice.aaroncharlton.com/randomize-6-numbers.php
Why would I want to do this? A use case:
Suppose there are six products in your stimuli that each have different prices. For tight experimental control, you want the prices to vary randomly between subjects. To do this, you can create a web service to pull in the shuffled numbers. Then, you can assign each number to a variable using Qualtrics’ embedded data.
Getting it in to Qualtrics
1. Log in to Qualtrics, edit study, and click on “survey flow.” It will give you the following options when you go to add a new element:
Click on “Web Service.” Now, you can add your web service URL to the URL field. Next, click “Test URL.” Check the box for “select all,” then click “add embedded data.” Your next step is to insert this embedded data in your survey at the proper points. The steps thus far have only generated the embedded data so that it is available to use.