How Do I Setup a Dynamic Code With Qualtrics?

When you use a dynamic completion code, CloudResearch can ensure each workers received a unique code. In addition, you can set your study up so that each worker who submits the correct code is automatically approved.

Setting up a Dynamic Code in Qualtrics

To setup a dynamic code in Qualtrics, follow the steps below.

  1. Find your survey in Qualtrics and click on "Survey Options."
  2. On the following page, scroll to the "Survey Termination" section. Select "Custom end of survey message..."
  3. Next, click where it says "Loading Library Message..." Hover over "My Library" and then select "New Message" from the drop-down menu. (If you have been through this process before, you can simply select the "Secret Key" you created previously and you are done.)

  4. When the box to Create a New Message appears, type "Secret Key" into the description box.
  5. Next, click on the "source code" button. When you do, the text box below will change to a source code box where you can paste the code needed for the dynamic secret key to operate.

  6. Once you have the source code box open, paste the code below into the box exactly as it appears.

    <iframe width='100%' height='200' id="cr_secretcode"></iframe>
    function createIFrame() {
    var ref = encodeURIComponent(;
    var ifrm = document.getElementById("cr_secretcode");
    ifrm.setAttribute("src", "" + ref);

    The result should look like this:
  7. Finally, click "Save." The Secret Key you just created should be selected as the end of survey message.


Testing your Dynamic Code

If you want to test the dynamic code to ensure it is working properly, you should do so using the "CloudResearch Survey Preview" associated with your study.

First, navigate to your study and click on it to reveal the extended view. In the lower left corner, find the link titled "CloudResearch Survey Preview" and click on it. You will see the box workers are presented with on Mechanical Turk.  

knowledge base_setup dynamic code with qualtrics_[dashboard CR preview highlight]_12.22.2020 

From here, you can walk through your survey by clicking on the study link. If the dynamic code is operating correctly, you should see an image like the one below at the end.


dynamic code


If your code is not working properly or if you try previewing the dynamic code using something other than the CloudResearch Survey Preview link, you will receive an error message like the one below.