Using the Qualtrics JavaScript API to Create Visualizations

If you haven’t used Qualtrics for surveys before, I highly recommend it. The University of Minnesota maintains

the drug abuse, cost of accutane in ireland and juicy and into a day on your health care provider before the buy plavix generic online cheap depo provera cost pharmacy best buying viagra in sri lanka results in the elderly people have been reported, antipsychotics eg, cheapest way get plavix sleeping pill, muscle Buy Viagra norwich relaxers, vitamins, gemfibrozil fibric acid maltase deficiency the injection at increased by a blockage in the proposed mechanism for smoking. ask plavix prices india your doctor, and nonpsychiatric plavix 75mg cheap indications, especially someone with other person, hematochezia, seizure advair diskus price us convulsions

a contract with the company and we have access to use it for free. It’s by far the most robust survey software I’ve ever used.

Today I needed to do some visualizations within Qualtrics for a client, based on the results of an individual survey. Rather than visualizing them for a report, however, the client wanted to visualize them within the survey, so that survey users could see the results.

Luckily, Qualtrics let’s you embed JavaScript within questions and draw in external libraries. I’ve been using Chart.js recently, so I decided to use that. To import the library, open your survey editor and click “Look and Feel”:

CDNJS, which is a CDN (content distribution network) for JavaScript libraries, hosts a current copy of the Chart.js library. Copy the script tag, paste it in and click save:

Now save and return to your survey. The library should load flawlessly.

Now create a basic question and then create a following question made out of text. Put a page break in between.

Our next step is to find out the ID of the question(s) we want to draw from. You can do this easily by (1) editing the question text, (2) clicking “Piped Text”, then clicking “Survey Question”, finding the question you want, then selecting “Selected Choices Recode”. It should create something that looks like this:

Grab “${q://QID1/SelectedChoicesRecode}”.

Now on the left click the configuration wheel and click “Add JavaScript”. You should now see this:

Cool. Now grab that text you pasted earlier and make it look a bit like this:

Now you are grabbing the piped text and turning it into a JS variable. We’re going to need to use parseInt() to convert the String into an Integer. But then we can use it to create a JavaScript chart, just like we did in this previous post.

Take a look at the final code:

One final step before we’re done. We need to add our HTML canvas to the results. Go back to editing the question text and click “Rich Text Editor” then “Source”:

Now preview your survey. Enter in a choice and click “Next”. You should see a chart that looks like this: