How to transfer Participant number from one pavlovia experiment to a second one using "Completed URL"?

I am following a guide posted by another user on here that allows you to automatically generate a random participant number from Sona, and transfer it to Qualtircs, then to a Pavlovia experiment and then back to Sona to deliver credit.
The guide looks like this:

SONA → Qualtrics → Pavlovia → SONA

-and was found on this thread: SONA, Qualtrics, Pavlovia
(for some reason, I cannot attach it to this thread, but it can be found on this url)


My experiment is broken up into two parts. Part 1 and Part 2. In the Completed URL section of Part 1, I have added the URL for Part 2, and participants are automatically directed there. How do I automatically push the participant’s number from Part 1 to Part 2?

it will look like this:

SONA → Qualtrics → Pavlovia Part 1 → Pavlovia Part 2 → SONA

                ^^ How do I push participant number from Part 1 to Part 2?

The principle is the same as any other Completed URL


Thanks for your help! I am having two issues.

When using that code I end up with an error when trying to push to pavlovia.
I have this in the completed URL field:

The error says this:
Traceback (most recent call last):
File “/Applications/”, line 1221, in onPavloviaSync
File “/Applications/”, line 719, in fileExport
File “/Applications/”, line 73, in generateScript
File “/Applications/”, line 242, in compileScript
File “/Applications/”, line 214, in _makeTarget
File “/Applications/”, line 225, in writeScript
File “/Applications/”, line 598, in writeExpSetupCodeJS
TypeError: str returned non-string (type NoneType)

Any idea what is wrong?

Question 2. Following that guide, should the “Participant” field be automatically filled in with the randomly generated participant number? when testing out the connection to Part 1, I noticed the field was blank still.

Check you are using dumb quotes by deleting and reinstating them in the URL field.

Check you have double quotes around the text and single around participant.

Hmm, good catch on the quotes. I am not getting any errors but it does not seem to be pushing the info between part 1 and part 2 still.
I have the following in the completed URL section for Part 1:
$“Rapid Holistic Perception Part 2 [PsychoPy]”+expInfo[‘participant’]

When the user is redirected to Part 2, the participant field shows and it is blank.

It looks like it is pushing fine from Sona and Qualtrics because I do not see a participant field.

Part 2 still shows the participant field.

What does the URL look like in the address bar for the second experiment?

it now says this and it pushed! I think its working!!

1 Like

The problem now is that the id is not being pushed from Pavlovia to Sona. It looks like my Sona redirect URL looks different than the guide. Specifically it ends with: &survey_code=${e://Field/id}

the full url looks like this.

This is what I have in the Completed url field:

  1. Sona pushes to Qualtrics= randomly generated id

  2. Randomly generated id converted to “participant” for Part 1
    Rapid Holistic Perception Part 1 [PsychoPy]

  3. Part 1 pushes participant to Part 2
    Rapid Holistic Perception Part 2 [PsychoPy]

  4. Part 2 pushes to pavlovia
    Psychology Research Participant System

This is Qualtrics code and therefore has no place in the PsychoPy completed URL field. It doesn’t matter what the variable name is. You need to pass the value from Sona back to Sona.

Hmm… So this does not work either:

-for some reason I cannot accurately cut and paste it.

I guess I am having trouble figuring this out. I also tried:
$“Psychology Research Participant System”+expInfo[‘participant’].

I do not know enough about the actual coding and have to rely pretty heavily on the code and instructions in the guide and suggestions I get on here. Thanks so much for your help. Do you have any idea why its still not getting from Part 2 to back to Sona?

Why do you have an extra dollar sign after survey_code= ?

I tried both ways. I tried like this as well

That looks correct. Is the correct survey_code being received by the experiment on Pavlovia as participant?

Yes. When I tested it, I tracked the participant number in the URL from Sona to Qualtrics, to part 1, to part 2. It is only when it is supposed to be passed from part 2 back to Sona that there is an error.

12574 is the practice number generated. As you can see in the picture, it is passed from Sona to qualtrics to part 1 to part 2. between part 2 and Sona there is a problem.

if I enter the URL and make the survey_code = to 12574, it works. As you can see in the images below. So for some reason, on part 2, survey_code=’+expInfo[‘participant’] is not working.

What version of PsychoPy are you using? I’m still on 2020.2.10 because I’m not yet confident with version 2021.

1 Like

You could try pushing Pavlovia 2 to a random website (e.g. back to Pavlovia 1) just to check whether the survey code is appearing in the URL – we don’t see it whether the number is still there.