# Participant ID not saving in data file name

**URL:** <https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623>\
**Category:** Online experiments\
**Created:** [August 30, 2022, 7:21pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623 "2022-08-30T19:21:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hrb](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hrb](https://discourse.psychopy.org/u/hrb)\
**Post date:** [August 30, 2022, 7:21pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/1 "2022-08-30T19:21:05Z")

</div>

URL of experiment:  
[https://run.pavlovia.org/sokolhessnerlab/cgtgamblingspantasks](https://run.pavlovia.org/sokolhessnerlab/cgtgamblingspantasks)

PsychoPy version: 2022.2.1  
OS: MacOS 12.3.1

Description of the problem:  
We are using daisy chaining to pass participant IDs throughout our study (Prolific ID gets passed to Qualtrics, then Pavlovia, then Qualtrics again).

The participant ID seems to successfully be passed from Qualtrics to Pavlovia as it shows up as a variable in the .csv data file at the end of the experiment but the participant ID is not saved in the .csv file name. Instead the filename is saved as “\_studyName\_dateAndtime.csv”.

It seems like the expInfo[‘participant’] variable is treated as empty when the data file name is created. However, this is odd because the expInfo[‘participant’] works fine when creating the redirect URL (the participant ID is successfully passed on from Pavlovia to Qualtrics).

In the .js script, the datafile name is created like this:

```auto
 psychoJS.experiment.dataFileName = (("." + "/") + `data/${expInfo["participant"]}_${expName}_${expInfo["date"]}`);

```

and then a few lines below that, the redirect URL is set:

```auto
  // add info from the URL:
  util.addInfoFromUrl(expInfo);
  psychoJS.setRedirectUrls(('https://udenver.qualtrics.com/jfe/form/SV_a4qaGzutOwOjcPk?PROLIFIC_PID=' + expInfo['participant']), 'https://app.prolific.co/submissions/complete?cc=C7B3UXTE');

```

Both of these blocks of code use the same variable expInfo[‘participant’] but for some reason the participant id is only showing up in the redirect URL but not the data file name.

The participant ID is included in both the .csv file and the .csv file name when I manually input a participant ID into the dialogue box at the start of the experiment, so the issue is only happening when trying to pass the participant ID using URL.

The experiment otherwise runs smoothly from start to finish, just having this one issue.  
Thank you in advanced for any insight!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [August 30, 2022, 7:42pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/2 "2022-08-30T19:42:59Z")

</div>

Please could you paste your Qualtrics code and show your expInfo dialogue box. I’m wondering whether you’ve put Participant instead of participant somewhere.

---

<div class="post-metadata">

**Author:** ![hrb](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hrb](https://discourse.psychopy.org/u/hrb)\
**Post date:** [August 30, 2022, 8:01pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/3 "2022-08-30T20:01:54Z")

</div>

Thanks for the reply @wakecarter. I’ve included those things below (is the screenshot showing what you meant by dialogue box?).

Qualtrics url  
`https://run.pavlovia.org/sokolhessnerlab/cgtgamblingspantasks/?participant=${e://Field/PROLIFIC_PID}`

 ![Screen Shot 2022-08-30 at 1.58.45 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/0/8066eab680ffc9bfd5b48d8c63c45c43bc97763d.jpeg)

(For what its worth, I have tried unchecking “show info dialog” and that doesn’t seem to make a difference.)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [August 30, 2022, 8:10pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/4 "2022-08-30T20:10:19Z")

</div>

Those both look correct. Are you setting the PROLIFIC\_PID in embedded data in Qualtrics? Are you sending it as that variable name from Prolific? To test the Qualtrics / Pavlovia connection you could set PROLIFIC\_PID as a fixed or random number in Qualtrics to check it’s coming though.

---

<div class="post-metadata">

**Author:** ![Yiannis](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/yiannis/32/35056_2.png) [@Yiannis](https://discourse.psychopy.org/u/Yiannis)\
**Post date:** [August 30, 2022, 9:18pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/5 "2022-08-30T21:18:07Z")

</div>

I’ve asked the same question before. The response was this is a bug. I don’t know if this has been fixed in the newest release 2022.2.4 though  
[Participant info not saved on filename.csv - Online experiments - PsychoPy](https://discourse.psychopy.org/t/participant-info-not-saved-on-filename-csv/30029/7)

---

<div class="post-metadata">

**Author:** ![hrb](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hrb](https://discourse.psychopy.org/u/hrb)\
**Post date:** [August 30, 2022, 9:37pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/6 "2022-08-30T21:37:18Z")

</div>

Thank you @Yiannis for sharing that!

---

<div class="post-metadata">

**Author:** ![hrb](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@hrb](https://discourse.psychopy.org/u/hrb)\
**Post date:** [August 30, 2022, 9:40pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/7 "2022-08-30T21:40:23Z")

</div>

Yes, PROLIFIC\_PID is set as embedded data in Qualtrics. I can tell that the Prolific ID is getting passed along from Qualtrics to Pavlovia because it is getting saved inside of the data file and is saved under the column ‘participant’ in the data file, its just not getting saved in the file name itself. It looks like this is a bug (see reply above). Thank you @wakecarter for the help!

---

<div class="post-metadata">

**Author:** ![shabkr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/shabkr/32/32052_2.png) [@shabkr](https://discourse.psychopy.org/u/shabkr)\
**Post date:** [August 31, 2022, 9:38pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/8 "2022-08-31T21:38:33Z")

</div>

Hi @hrb and @Yiannis,

I have also encountered this issue ( [Possible Bug: 2022.1.1 - 2022.1.3 URL Parameter not included in filename - Online experiments - PsychoPy](https://discourse.psychopy.org/t/possible-bug-2022-1-1-2022-1-3-url-parameter-not-included-in-filename/29080)).

Just wanted to let you know that the bug still seems to exist in 2022.2.4.

If you go back a year to 2021.2.3, I tested that version and it does not have the bug.

-shabkr

---

<div class="post-metadata">

**Author:** ![young1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/young1/32/7428_2.png) [@young1](https://discourse.psychopy.org/u/young1)\
**Post date:** [September 16, 2022, 8:17pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/9 "2022-09-16T20:17:55Z")

</div>

Seems like a quick manual fix on js files would solve the issue:

// add info from the URL first:  
util.addInfoFromUrl(expInfo);

// then add filename to psychojs experiment  
psychoJS.experiment.dataFileName = ((“.” + “/”) + `data/${expInfo["participant"]}_${expName}_${expInfo["date"]}`);

I confirm that file saves well with URL params this way. I tested with recent psychopy version 2022.1.2

---

<div class="post-metadata">

**Author:** ![shabkr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/shabkr/32/32052_2.png) [@shabkr](https://discourse.psychopy.org/u/shabkr)\
**Post date:** [October 11, 2022, 6:32pm UTC](https://discourse.psychopy.org/t/participant-id-not-saving-in-data-file-name/30623/10 "2022-10-11T18:32:07Z")

</div>

This is a great option. I tried adapting your suggested code to use a code component instead of manually modifying the JS files. I tested the below in version 2022.2.4.

I added a **Javascript-only** code component. In the `Before Experiment` section of the code component I added:

```auto
util.addInfoFromUrl(expInfo);

```

as you suggested (doesn’t seem to need the second line).

Using a code component means you hopefully won’t have to make manual adjustments to the js files.
