I have participants entering their email address in a text field on a single page survey. I want to take the part that appears before the @ in the email address and assign it to a new embedded data variable.
For example, if I entered jonese@ email.com (extra space added after the @ to avoid linking to a fake email) in the text field, I would want to assign the string “jonese” to the embedded variable.
Here’s the code I have that isn’t working:
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
var kkiEmail = "${q://QID12/ChoiceTextEntryValue}";
var getUsername = kkiEmail.split("@");
Qualtrics.SurveyEngine.setEmbeddedData("username",getUsernamea0]);
});
Any suggested JavaScript syntax and guidance on where it should be placed would be greatly appreciated!
Thanks!
Erin