Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
Javascript patch to grab MTurker ID

I am trying to use the snippet of code below to embed MTurkers' worker IDs as part of a URL. When they click the redirect URL, it sends them to a task, and if I can attach their worker ID to the URL my task will grab that embedded data so I can identify them later. However, the code is not grabbing their ID. Someone offered a modification to the code that should fix it, but I can't figure out where to put the new code.

This is the original code:

<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>

This is the part I'm supposed to add to fix it:

var current_url = new URL(window.location.href);
var workerID = current_url.searchParams.get("workerId");
console.log("The worker ID is: " + workerID);

Where should I put it?

(PS link to the post where I got the code.)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda