How to make a global variable in Qualtrics | XM Community
Skip to main content
Hi,





I've made a lot of custom code using javascript across many questions in my Qualtrics survey. Each of the questions uses the same variable and since the variable is an extremely long list of names and for the sake of neatness I want to make a global variable such that custom code in each question will call upon this variable without having to input into each questions custom code section.



These questions cannot be combined to a set of multiple form fields. They must all have separate question IDs.



Any help will be greatly appreciated!
You can use custom CSS under look and feel.
@bansalpeeyush29 I tried inputting the variable in the custom CSS part, but it didn't seem to work. Do I need to add a <script> tag before and after the variable to make it work?



update: I tried adding a <script> tag before and after the variable in the custom css portion and the variable was not recognized in my custom code
Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.
ah okay I figured out the issue. The list of names had a name with a ' which wouldn't let the code run. Once that was fixed everything worked out

Leave a Reply