Description of the problem: In my study I have a code component that randomly assigns people to different conditions. I would like to export this condition variable to qualtrics using a query string. However, in qualtrics the variable is showing up as ‘undefined’. I looked through the javascript and the redirect URL is above the point where my condition variable is defined.
If anyone else has a javascript solution, I would love to check it out.
In the meantime I was able to figure out a workaround and wanted to share it with anyone else who has the same issue.
In my study flow, I am linking SONA to Qualtrics to Pavlovia to Qualtrics and back to SONA. SONA creates a unique id for each participant which I am using as a participant number. The first qualtrics study is the consent form, and passes the participant number from SONA to pavlovia. In the first Qualtrics survey, I set up a new embedded condition which randomly selected the condition. I then passed this from Qualtrics to Pavlovia. This ensures that the condition variable comes before the redirect URL.
Here is a screenshot of the Qualtrics Survey Flow:
Sounds like you have found out lots of useful information about the issue already. Please can I check what version of PsychoPy you are using? the newest version has a “Before Experiment” tab in the code component, which might allow you to implement the JS code component you mention there before the redirect url.
Thanks,
Becca
EDIT: saw that you found a solution after posting to your initial question - pleased you found a work around and thanks for sharing your solution