When posting a Qualtrics survey link on MTurk, here’s how to capture a worker ID as embedded data:
First, create a HIT (Human Intelligence Task) normally, selecting the Survey Link template type. Continue setting up your hit normally until you arrive at the Design Layout tab, then click the Source button and replace the entire contents with the following code. (Note that about halfway through the code snippet is placeholder for a link to your survey. You’ll need to replace https://YOUR_QUALTRICS_SURVEY_URL_GOES_HERE with your survey URL.)
(I will provide a rubber duck debug explanation in this paragraph, but skip it if you are not interested in the technical details.)
- Lines 25-32 examine the URL of the page; if it contains a parameter equal to workerId, the mturkworkerID variable is set to the workerID value.
- Line 33 is a conditional statement that looks to see if the mturkworkerID has been set. If it has not, the text of the myelementLink div should be updated (alerting a user that this URL will be revealed once the HIT is accepted).
- The survey link is formed in line 36, where you should have a valid workerID . “https://YOUR_QUALTRICS_SURVEY_URL_GOES_HERE&MID=’ + mturkworkerID + ‘” is appended to the Survey URL. This will set the mturkworkerID value to MID embedded data field within the survey.
- Everything after line 36 is the remainder of the untouched MTurk template.
Once you have pasted the snippet, click the Source button again. You should see the following text when previewing the layout:
Within Qualtrics you’ll need to add two pieces of embedded data to your survey within the Survey Flow, as shown below:
The MID will be set to the MTurker worker ID. You then must set a random number between 1000 and 9999 as the code that the MTurker provides once s/he completes the survey. Both of these data fields will be saved in the Qualtrics result set.
Within this demo video you can see me completing a HIT with this setup:
Oh, and lastly – I’d be remiss not to give credit to Eyal Peer , whose post on this subject provided the code snippet. Thanks, Eyal!