Hello,
I need to be able to send email triggers that contain a URL with piped text using a text response from users. When the response contains spaces, it causes an error. It seems I need URL encode the text response for the piped text in the email trigger. I am totally unfamiliar with javascript but it seems it's the only way to accomplish this. Can anyone provide the solution I need? Instructions for implementing would be much appreciated as well.
Page 1 / 1
Add this to the bottom area of the javascript screen for the question that has the code you want to encode for a URL:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var qid = this.questionId;
var textFld = document.getElementById('QR~' + qid);
var textRsp = textFld.value;
var altName = encodeURIComponent(textRsp);
Qualtrics.SurveyEngine.setEmbeddedData("AltSiteName", altName);
//console.log('url name is: ' + altName)
});
What it does is to read the text response, encodes it for URL, and then sets it into an embedded data variable called altName. You can then pipe altName into your final url. If you have several questions, you will have to use different names for the embedded data.
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var qid = this.questionId;
var textFld = document.getElementById('QR~' + qid);
var textRsp = textFld.value;
var altName = encodeURIComponent(textRsp);
Qualtrics.SurveyEngine.setEmbeddedData("AltSiteName", altName);
//console.log('url name is: ' + altName)
});
What it does is to read the text response, encodes it for URL, and then sets it into an embedded data variable called altName. You can then pipe altName into your final url. If you have several questions, you will have to use different names for the embedded data.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.