Py-Script support with Qualtrics Survey | XM Community
Skip to main content

Hi community,
Just wanted to share a cool experiment I tried on Qualtrics. If you are a python developer or following the recent announcement of Py-Script by Anaconda which allows running python scripts from your HTML pages you may find this interesting.
My initial motive was to test if it actually works with Qualtrics, next would be finding use-cases if it actually worked.
Spoiler - It worked!
To test this first I wrote a few lines of python to generate a bar chart showing Revenue Growth. Next, I formatted the code along with all the dependencies as shown in the documentation of Py-Script.
You can test it by just pasting the below code snippet into the HTML view of a question on Qualtrics Survey Builder.



- matplotlib
- numpy


import matplotlib.pyplot as plt
import numpy as np

x = np.array(["2018", "2019", "2020", "2021"])
y = np.array([100000, 150000, 92000, 360000])

plt.bar(x, y)
plt.title("Revenue Growth in the last 4 years")
plt


Survey Preview -
image.png
The displayed chart is not a pre-existing image but purely generated by the python script.

Conclusion:
Thus my test was a success in incorporating python snippets on Qualtrics. This could open ground for new ideas or use-cases. Maybe use python to connect to an external DB depending on the survey responses, run automations already written in python, process a file uploaded by the respondent, display charts and graphs at run-time as shown in the above example.
Would like to hear the community's thoughts on this.
Thanks,
Atharva

Please share all the code! What did you have to put and where? I am trying to use pyscript and it is just hanging. If you could share how you got this to work, I’d be so appreciative!!!


Hi all, I have code in Python for a dynamic graphic that changes with a slider (for the survey respondent to use), and I’m trying to embed it into Qualtrics. Has anyone had any luck with something similar, or just using Python in Qualtrics in a more dynamic way?


Hello @AtharvaKatre, for my master thesis I am making a survey where I want to use response from questions in block 2. I want to run these responses trough a python function an reuse the output of it in a question in block 4. Can you explain how you got your Python function work in Qualtrics? Maybe can you share the code of your example?  

Thanks! 


Leave a Reply