Custom questions using data sampled from the rows of a Google Sheet | XM Community
Skip to main content
Hi Qualtrics Community!



A recent experimental need here at Stanford has been to make surveys with questions whose content is customized based on samples from a Google Sheet. But these samples couldn't be _completely random_; rather the samples needed to enforce some structure like uniformity across views by respondents (e.g., one customized question is seen no more than N times). This type of sampling strategy requires maintaining a "global state" separate from the clients.



We couldn't use the Google APIs, which can be imported into custom Qualtrics `javascript`, because they (appear to) require client-side `OAuth` logins to write to _any_ sheet, including one owned by the experimenter. Our respondents can't be asked to log into their Google profiles to help us maintain a global state for sampling.



Our solution was to build a custom backend API in `node.js`. This API can run on some server (e.g., in AWS EC2 or GCE), load a Google Sheet using Google's API for `node.js`, and serve custom question data of _any_ form suitable to inclusion in the rows of a Google sheet. You can get sampled data with a simple `fetch` call and what you do with that data in the Qualtrics questions is up to you. The API maintains the global state and has a few sampling strategies that enforce both strict and weak sampling limits, as well as simple uniform sampling.



The full repo (which I would consider still "alpha") is available here. I would hope you find this useful if you have a need to do this sort of customization in Qualtrics. Feel free to post issues if you have problems or feature requests, or contact me with questions.
This is a really great tool, hope some people find use for it! Thanks for sharing!

Leave a Reply