CompletedURL / IncompleteURL

How about setting my_url to just “good” or “bad” and then using

"" + $my_url


Yes, I could try that but just realized I was unspecific. In my case I would set two completely different URLs. More like:

if accuracy >= 0.5:
    my_url = “/completely_unique_url_A”
elif accuracy < 0.5:
    my_url = “/totally_different_url_B”

and then set completedURL in the experiment settings to $my_url.

So the URLs are completely different and I can’t just append a variable like an ID.

1 Like

Thanks for your idea. Unfortunately that didn’t work for me, because in the js the variable was still created after the redirect link was set. I just moved the generation of the random code to an earlier point in the .js directly. That fixed the problem for me. This of course wouldn’t work for something as @lnnrtwttkhn is looking for where the URL actually depends on the performance in the task.

1 Like

So did it need to be in a Begin Experiment block?

No, that’s where I had it initially. But this was still “too late” as the redirect link is established very early on in the .js file. I manually edited the .js after doing everything else in Builder first.

Thanks for the clarification – so basically it can only take expInfo variables, not ones created during the experiment.

Yes, the issue is that the call to redirect to this URL is pre-scheduled at the top of the study and, at that point, your variable doesn’t exist.

There is a function in psychojs setRedirectUrls that you could use though in a code component. I think you’d just need to add something like this to your study after you’ve chosen the URL the redirect should point to:

PsychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

Note that this function doesn’t perform the redirect. It simply determines where to go later, whenever the study ends


Just a minor comment: It should be
psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

starting with a small letter. I tried and after I changed this everything works like a charm now, so thank you @jon for this solution!

1 Like

Hi Jon,

Since I do not have access to Qualtrics, I want to redirect the participants to a google form at the end of my Pavlovia experiment. I followed the above method and put this in the completionURL tab of online experiment in PsyhoPy:
$“” + expInfo[‘Participant’]

When I try to run this on Pavlovia, I get this message : Dynamic Link Not Found.
(The URL works fine as long as the + expInfo[‘Participant’] is not added.)

Please tell me if I am doing anything wrong here?

You are missing the ?varname= at the end of the static part of the URL


I am sorry to ask this but what exactly is the ‘varname’ here? Is it the field in the google forms that refers to the subject’s identity?

I set the completionURL to this:
$“” + expInfo[‘Participant’],
where subject ID is a field in google form and participant a field in the Pavlovia dialog box. The link works just fine now. But, how do I trace this participant id as a subject’s identity in my google form response sheet?

Off the top of my head, I’m not sure whether Google forms can read URL variables. You’ll need to Google that to check.

So it looks like the google forms cannot read URL variables. In that case, is there any other way to work around the issue of matching identities in pavlovia and google forms?
For example, asking the participants to fill their IDs in forms assigned to them in pavlovia (if that happens) or collecting mail ids on both platforms?

These are just some things on top off my head. Could you please suggest a more streamlined solution?

@Surabhi_Lodha maybe you have already found a solution but you could potentially ask participants to generate a code themselves according to a set of rules, it is usually like 6 elements long like initials of your mother, month of your brother’s birthday, last letter of your name etc. I am sure you would find a template for that online. You could ask participants to generate that code in Pavlovia and save it in that data, and then ask participants to generate it again in your Google forms so that you can link the data

@dvbridges could you please explain in which cases the incomplete URL actually kicks in. I tried to test it by running my experiment and then at the first instruction screen I just pressed Esc but the re-direct doesn’t happen. When I close the tab it just asks whether I want to leave the page which I confirm and the tab closes. Any ideas? Thanks

Press escape twice (the first just exits full screen) or have a core quit statement (appropriately translated)!in a code component

1 Like

Thank you for that. Pressing ‘escape’ twice is something that participants would never do, so I think it is a poor trigger for the incomplete URL to be honest.

For the sake of completeness, I am posting my solution for how to define the URLs here as the solution from your crib sheet did not work for me @wakecarter. I am using a code component to run at the beginning of the experiment. Otherwise, giving several information to the link did not work for me. Hence I created it as a string as a code component and defined the links manually.

myCompletedURL = `${expInfo["id"]}&ComboIndex=${expInfo["ComboIndex"]}`;
myCancelledURL = `${expInfo["id"]}`;
psychoJS.setRedirectUrls(myCompletedURL, myCancelledURL)

Am I right in thinking that there is no way using PsychoJS to disable the exit from the full screen upon pressing escape?

The only way then to give participants an early out with a re-direct then is to tell them to press a specific key, e.g. ‘q’ to exit which I got working with the snippet below. Am I right in thinking that this would need to be checked every frame in an experiment?

 if (psychoJS.eventManager.getKeys({keyList:['q']}).length > 0) {
    message = "You ended the experiment early. Please press 'OK' to close the session."
    quitPsychoJS(message, false);

but doing the same with escape no matter whether escape is enabled or disabled in the builder settings does not work.

What I have figured out just now is to disable the escape key, and check in every frame of a given routine whether we are still in full screen mode or not. If not, then it will assume that the participant is leaving and it will re-direct to the incomplete URL :slight_smile: Happy days!

if (document.fullscreenElement === null) {
    message = "You ended the experiment early. Please press 'OK' to close the session."
    quitPsychoJS(message, false);
1 Like

I’m having some trouble getting my psychopy experiment to redirect to another psychopy experiment and use the same participant ID.

I am using Wakefield’s app to generate sequential IDs ( and my experiment file uses the following code which was set in the completed URL field of the psyexp experiment settings:

// add info from the URL:
  psychoJS.setRedirectUrls('""+expInfo[\'participant\']', '');

But when the reversal learning script is done it appends the completed URL to the reversal learning study URL w/o participant, and this leads to a 404 not found.""+expInfo['participant']

Is my redirect not defined correctly?

Here’s the link to the public study repository if that helps:

I think you’ve overdone the quotes. I’ll try to correct your code tomorrow

I believe it was an issue with the quotes because I upgraded to 2020.2.5 and it was changed to the following, which works correctly

psychoJS.setRedirectUrls(('' + expInfo['participant']), '');

I stumbled upon this thread when looking for a solution when the suggested $"<url>participant="+expInfo['participant'] didn’t work (and Qualtrics was taking expInfo[‘participant’] as a literal string).

What I found to be the key was that the quotation marks used must be double and simple (as opposed to “smart” (<<< as in those <<<) and single, even for the expInfo parameter.

Therefore, the Completed/Incomplete URL fields on the Online tab of Experiment settings need to be:


where Qualtrics is expecting a value for id, <url> is replaced with the relevant Qualtrics URL, and the rest is exactly as above. For example, a test survey of mine is:


Hope this helps someone some time. :smiley: