Tuesday, August 26, 2014

How to transfer MTurk workers' IDs to your survey on Qualtrics

The following steps will enable you to transfer a MTurk worker's ID from MTurk to your Qualtrics survey:
  1. Create a new HIT on MTurk and, in the Design Layout section, switch to source code mode. 
  2. In the place where you want your survey link to appear, enter the following script:
    <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&MID=' + mturkworkerID + '"><h1><span style="color: rgb(255, 0, 0);"><span style="font-family: Courier New;"><b>CLICK HERE TO TAKE THE SURVEY!</b></span></span></h1></a>';
    }

    // --></script>

    <div class="link" id="linkDiv">&nbsp;</div>


  3.  Replace the survey url in the code (where it says "YOUR_QUALTRICS_SURVEY_URL_GOES_HERE") with your survey url. (make sure there is no space between the survey url and the code that follows it).
  4. Switch back to regular edit mode. You will see, where the survey link should be displayed, a message that says "URL not shown because there is an error with JavaScript on your computer...". This is normal. Don't worry. 
  5. Move to the Preview and Finish mode. Now the error message should be replaced by "The link will appear here only if you accept this HIT.". This is how your workers will view the HIT (if the error message still appears, you did something wrong and it won't work). 
  6. In your Qualtrics survey, add an embedded data element in your survey called MID, and set it to be populated from the survey url. This will store each worker's ID in your survey data. 
  7. Publish your survey through your HIT and collect your data! 

Note on asking workers to accept your HIT beforehand: Some workers object to accepting a HIT beforehand. The method above requires it. What I do to appease workers is add some text that says "We have to ask you to accept this HIT because we need to verify that you have not completed this survey before. According to MTurk support, accepting and then returning HITs does not affect your account or your eligibility to complete other HITs." 

In some case, I also add the full survey url (without the script) so workers who really object to accepting HITs beforehand can use it. This, of course, will defeat your original goal so it's up to you whether you want to do it or not. From my experience (and also some data I collected), HITs that use the above method show similar response rates to those that do not. In the past, I used to get some complaints from workers, but these died out in the recent months so maybe workers are getting used to this type of request. 

Best of luck in your research!