0 votes
in SoSci Survey (English) by s139639 (360 points)

I am tring to find another way (rather than directly asking people for their worker IDs). Do you have any code that could enable that? I saw that it was done automatically in Qualtrics, but I'm wondering if it's the case for SosciSurvey. Thank you in advance!

2 Answers

0 votes
by SoSci Survey (305k points)
edited by SoSci Survey

The most recent information from the Amazon API documentation was that the worker ID is not published automatically. The official information from Amazon is:

To verify that Workers actually complete your survey, require each Worker to enter a unique survey completion code to your HIT. Consult with your survey service provider on how to generate this code at the end of your survey.
(https://requester.mturk.com/create/projects/new)

This is also what Qualtrics explains on their website:
https://www.qualtrics.com/support/survey-platform/common-use-cases-rc/assigning-randomized-ids-to-respondents/

And there are also instructions on the Internet that say that you need to ask for the WorkerID in Qualtrics as well: https://jessicaeblack.org/research/tips-on-using-mturk-with-qualtrics/

We will evaluate the options to circumvent this necessity by using the MTurk developer options. Should you have any different information (about MTurk or Qualtrics), please let us know.

Update: Here is the manual how to work with MTurk in SoSci Survey: Amazon MTurk

by s139639 (360 points)
Hello, thank you very much for your reply. Sorry for insisting on this matter, but It is important because I want to be sure of everything before I start collecting a large-scale data. I think It is possible to capture the workers ID by reprogramming a code in Amazon Turk, however I would need to insert an "embedded data" variable in soscisurvey. So, should I create an internal variable to do so? I am not sure which variable in sosci survey can capture the worker ID in this case? Do you have a code that would help me do that? So sorry for the inconveniece! Thank you very much in advance!
by SoSci Survey (305k points)
> I think It is possible to capture the workers ID by reprogramming a code in Amazon Turk

If you have any information on this, please let me know. I did not find something about that so far.

> however I would need to insert an "embedded data" variable in soscisurvey. So, should I create an internal variable to do so?

Depends on "embedded data" means specifically. Please send me more specifications about the context.

> I am not sure which variable in sosci survey can capture the worker ID in this case?

You can story anything in an internval variable. The question is how the information comes from Amazon MTurk to SoSci Survey.

And this is where I need the information that you say you have, but I do not yet have.

You are very welcome to insist on this matter. I gladly provide a more convenient solution for Amazon MTurk, but as I wrote ... I do not yet have any information that allows me creating a solution. So please feel free to send me the information that you have!
by s139639 (360 points)
Hello, thank you very much for your reply. These are the steps we follow in Qualtrics (should apply to sosci survey as well). First, follow these steps in Qualtrics:  
1.    Survey flow
2.     Add a new element here
3.    Embedded data
4.    In the box, delete the text that reads, “Create New Field or Choose From Dropdown...,” and type MID (case sensitive).


Next, in MTurk, follow these steps when setting-up the HIT:
1.    Design layout
2.    Source
3.    Replace text with script below (make sure to replace the text https://YOUR_QUALTRICS_SURVEY_URL_GOES_HERE with your survey URL)
4.    Source
5.    Finish setting-up HIT

And this is a part of MTURK code we have modified.

<table>
 <tbody>
 <tr>
 <td><strong>Survey link:</strong></td>
 <td><div id="myelementLink" style="display: inline; font-family: Verdana;"><tt>URL not shown because there is an error with Javascript on your computer. To perform this HIT, you must have Javascript and cookies enabled on your browser.</tt></div>
<script type="text/javascript" language="JavaScript"><!--
var assignment_id_field = document.getElementById('myelementLink');
var paramstr = window.location.search.substring(1);
var parampairs = paramstr.split("&");
var mturkworkerID = "";
for (i in parampairs) {
 var pair = parampairs[i].split("=");
 if (pair[0] == "workerId")
 mturkworkerID = pair[1];
}
if (mturkworkerID == "" ) {
 assignment_id_field.innerHTML = '<tt>The link will appear here only if you accept this HIT.</tt>';
} else {
 assignment_id_field.innerHTML = '<a target="_blank" href=" https://YOUR_QUALTRICS_SURVEY_URL_GOES_HERE 7”?MID=' + mturkworkerID + '"><h1><span style="color: rgb(255, 0, 0);"><span style="font-family: Courier New;"><b>Click here to begin taking the survey!</b></span></span></h1></a>';
}

The problem is that I do not know how to create this embedded data in sosci survey
by SoSci Survey (305k points)
Okay, looks fair enough :)

To read the "MID" parameter that is inserted by your MTurk HTML modification, please create a question of type "Device and Request Variables".

In that question go to the tab "Variables (POST/GET)" and enter "MID" into the field for "Variable name (1)". Save the question, and drag it on the first page of your questionnaire.
by SoSci Survey (305k points)
PS: If that works, would you a allow me to add the MTurk code from above to the SoSci Survey manual? I think it could help lots of people :)
by s139639 (360 points)
Thanks a lot for your reply! Yes, of course! I will let you know if that work, and will send you the complete code if necessary.
by s139639 (360 points)
Hello. I have tried that, but unfortunately, it didn't work. I couldn't capture the worker IDs on the final dataset. Do you think that it is related to how we programmed the "MID" variable in sosci survey? In the final dataset, the variable name is not even shown (it was skipped).
by SoSci Survey (305k points)
You can try and start the survey with a variable MID added in the URL, e.g.

https://www.soscisurvey.de/mySurvey/?MID=123

If the variable is stored in that case but not when you start via MTurk, then your code on MTurk is not working. If the variable is not stored, then double-check if you have dragges the "device..." question on the first page of the questionnaire.
by s139639 (360 points)
So, this is an example of an external question data structure (as provided by Amazon Turk). Do you have an idea how I can do that using sosci survey? I am sorry for my lack of knowledge in programming.

<?xml version="1.0" encoding="UTF-8"?>
<ExternalQuestion xmlns="[the ExternalQuestion schema URL]">
  <ExternalURL>https://tictactoe.amazon.com/gamesurvey.cgi?gameid=01523</ExternalURL>
  <FrameHeight>0</FrameHeight>
</ExternalQuestion>
by SoSci Survey (305k points)
Yes, I know this example ... it does definitly not contain any MTurk Worker ID.
0 votes
by s139639 (360 points)

Hello, please find attached below some screenshots from the Amazon Turk blog, another solution is provided, but I am not sure how to do this on sosci survey (create an external question, and attach the worker ID on the URL of the survey). Actually, I have tried to do this with the "r" and "q" parameters, but nothing was displayed in the dataset neither.

this is the link: https://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_ExternalQuestionArticle.html

by SoSci Survey (305k points)
That one looks good! Especially this paragraph:

> Amazon Mechanical Turk appends the following parameters to this URL: assignmentId, hitId, turkSubmitTo, and workerId. For more information about these appended parameters, see the sections following this table.

So, what we probably need is the "workerId" variable. Give it a try and write this into your "Device and Request Variables" question in the tab "Variables (POST/GET)" as "Variable name (1)".

Please let me know, if you're getting a worker ID.

You should also see an URL in your browser when the worker is relayed from MTurk to the questionnaire. Please post the URL that you see, then.
by SoSci Survey (305k points)
Did you receive a worker ID with the variable "workerId" ?
by s139639 (360 points)
Hello, sorry for the late reply! I partially (I think because some respondents did not enable javascript in their browser) received worker IDs attached in a link (as reference), but the main variable didn't display the worker IDs (just the example of worker ID we inserted in the link). I am sure that it's a problem with the code (which I am trying to resolve). If the code is correct, it should be working fine.

This is the code:

var paramstr = window.location.search.substring(1);
var parampairs = paramstr.split("&");
var mturkworkerID = "";
for (i in parampairs) {
 var pair = parampairs[i].split("=");
 if (pair[0] == "workerId")
 mturkworkerID = pair[1];
}
if (mturkworkerID == "" ) {
 assignment_id_field.innerHTML = '<tt>The link will appear here only if you accept this HIT.</tt>';
} else {
 assignment_id_field.innerHTML = '<a target="_blank"
 href="https://www.soscisurvey.de/project0/?MID=' + mturkworkerID + '"><h1><span style="color: rgb(255, 0, 0);"><span style="font-family: Courier New;"><b>Click here to begin taking the survey!</b></span></span></h1></a>';
}

Any idea of what the mistake is in this code?
by SoSci Survey (305k points)
>  I partially (I think because some respondents did not enable javascript in their browser) received worker IDs

Your JavaScript code should not at all display the link to the questionnaire unless it finds a workerID.

I've been testing a bit and created a manual ... but it does not yet work. Should have a solution in few hours.
by s139639 (360 points)
Okay, I will try to fix the code as well. I will let you know if that works
by SoSci Survey (305k points)
Looks not so good. I have tried and collected all information available from the Workers' URL (your script just tried to extract the workerID parameter) - but there is only an assignment ID (and sometimes it is assignmentId=ASSIGNMENT_ID_NOT_AVAILABLE). No worker ID in the URL available...

You said that you had received worker IDs, anyway?

I will try and find the workerID somewhere else...
by SoSci Survey (305k points)
Okay, I also found your manual. It looks like this might be a bit outdated...
https://research-it.wharton.upenn.edu/news/capture-mturk-workers-ids-qualtrics-survey/
by SoSci Survey (305k points)
Update: If the assignment is made, then the worker ID will be sent in the request to the survey. However, I am unsure what the workers must do to enable the assignment.... I will have another try :)
by s139639 (360 points)
Hello, thanks a lot for you reply! I am not sure I understand what you mean by "the worker ID will be sent in the request to the survey"? To the best of my knowledge, this is not done automatically... Can you please enlighten me?
by SoSci Survey (305k points)
edited by SoSci Survey
> To the best of my knowledge, this is not done automatically...

I am currently running some more tests, and the results look promising at the moment. Solution 1: Add the question to store the workerId variable (in SoSci Survey) and use the Amazon template for surveys, but add a note that the workers should accept the HIT before the click the survey link.

Solution 2: A script to display the link only after the HIT was accepted. But I'm still optimizing that script. Therefore, that is not yet available. I've got a test batch running on MTurk, so I hope it will be done soon.
by SoSci Survey (305k points)
edited by SoSci Survey
Alright - solved the problem. Here's the solution:
https://www.soscisurvey.de/help/doku.php/en:survey:mturk
by s139639 (360 points)
edited by s139639
Hello. Thank you for providing the link! The code finally worked! Thanks a lot!
by SoSci Survey (305k points)
When you have the preview in MTurk, what exactly is displayed where the link should appear? Did you include the "device..." question on the first questionnaire page? Is anything stored in the REF variable?
by s139639 (360 points)
Sorry, it actually worked. The mistake I did is that I didn't modify this line : <section class="container" id="SurveyLink">\\

Once I did it, it worked fine! Thank you!
by s139639 (360 points)
Sorry to ask another question (just for my understanding), but I would like to understand the two modifications (scripts) you brought to the code. Is that possible? Thank you in advance! :)
by SoSci Survey (305k points)
You can download the full JavaScript by just opening the script URL in your browser (the first modification). What the script does is: It checks if there is a assignmentId und workerId in the URL on the respondent. And if there is, it copies the query that it "sees" on MTurk and attaches it to the link that will then be written into the form.

By and large the same that your script example from above does, but I thinks it's a bit more convenient.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...