Solved
How to Provide Code at End of Survey?
Hi Everyone:
I am putting together a survey where respondents will get a redeem code for a free drink upon submitting the survey. I want Qualtrics to get the one-time only code from a predefined list of codes in order to ensure the person did indeed complete the survey (so a person can't write in any code and get a free drink or use the same code over and over).
I came across the Rand function, but that does not use a pre-existing list, just a range of numbers that you set. Also, I am concerned it might generate the same number over time. Anyone know how to do this? Thanks in advance for your help!
Best answer by KoalaTricks
Can you control the drink codes? You could display the ResponseID embedded data field to users in the end of survey message (${e://Field/ResponseID) and have them redeem that for the drink.
https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/embedded-data/
Alternatively, you can set a quota for the number of codes you have available. When someone finishes the survey, they'll increment that quota. Then, in your end of survey message, you could enumerate and index the codes based on the quota count using Javascript (the quota field will change/be unique to your survey):
```
<script>
Qualtrics.SurveyEngine.addOnload(function()
{
var codes = ["code1","code2", "code3", "code4", "code5", "code6"];
document.querySelector("#EndOfSurvey").innerHTML = "Here's your code: " + codes["${qo://QO_UitB1v4imUFAuej/QuotaCount}"]
});</script>
```
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
