Possible to use a variable in Completion URL?

Win 10


I’m sure there’s a much easier solution to this, but I’m not seeing it.

Is it possible to make the completion URL a variable? Depending on the session #, the participant will see a different video. I then want the resulting completion URL to be different, as it will direct the participant to a qualtrics form that corresponds with that video. However, it appears the completion URL from settings is loaded before any of the code in the builder. Currently, I keep receiving

“ReferenceError: survey is not defined”. Anyone have any ideas on how to define $survey before it is called from settings, or a workaround?


I’ve tried placing the survey variable before experiment and at begin experiment, but no luck.


window.survey = ‘’;
if (expInfo[‘participant’] == ‘1’ && expInfo[‘session’] == ‘1’)
window.survey = ‘https://usmuw.co1.qualtrics.com/jfe/form/SV_7QBEZGv0PuZtmAe’;
window.vidDur = 15;
if (expInfo[‘participant’] == ‘1’ && expInfo[‘session’] == ‘2’)
window.survey = ‘https://usmuw.co1.qualtrics.com/jfe/form/SV_73dh8xcYxabXsnI’;
window.vidDur = 30;

Any input would be greatly appreciated.

Hi There,

You can’t currently make a completion URL a variable in the intuitive way you describe there. But you can using a code component. Add a code component, set code type JS and use something like:

if ((endTask)) {
    console.log("Test failed, redirecting to psychopy.org");
} else {
    console.log("Test passed, redirecting to pavlovia.org");

In this example endTask is a boolean variable corresponding to true or false, it is the logic used in the online bot checker demos demos / botChecker · GitLab

Hope this helps,


Much appreciated! This makes a lot more sense. I will mess around with this and see what happens. Thank you again.

It worked perfectly. Thanks so much!