I have the requirement to randomly redirect to a new page out of 4 links at the end of surveys. Since end of survey block do not have option to add javascript code, I put the redirection code in the previous block as below -
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
const chat_version = ["https://link1.com", "https://link1.com", "https://link1.com","https://link1.com","https://link1.com"];
setTimeout(function () {
window.location.href = chat_version[url_choice];},15000)
});
The above code sometimes work and sometimes doesn't redirect at the end of survey. I am unable to figure out the reason behind this. It's quite random and I cannot find the reason behind this.
Why dont you try to store each of these values in an embedded field.
Example : Link = Link1
Link = Link 2
Store these ED fields in a randomizer within the survey flow at the end of the survey and use the ED value within the End of survey to redirect to a random link
Thanks for the answer. I have to do this programmatically since I get the url_choice variable from my backend server. And I can redirect only based on that. I can't put them in the ranodmizer for this reason.
Although I cannot use radomizer, your answer helped me solved the issue. I didn't knew there is something like randomizer and there were two randomizer element already present in the End of Survey tag somehow and one of them was causing unintended redirect.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
