Hi all,
I’m working on a project where I would like to force respondents to click a link to take an assessment before continuing on in the survey. I’ve developed some code for this but have been encountering some problems:
- First, I was successfully able to hide the ‘next’ button, but when I clicked the link, the tab for the assessment didn’t open
- Then, I was able to code the link to open in a new tab when clicked, but qualtrics did not register this as a link click, and therefore didn’t reveal the next button.
Is there a way to force respondents to click the link, have it open in a new tab (so it doesn’t interrupt the survey), and have that register as the link click? We are trying to prevent respondents from lying about if they took the assessment.
Version of code that opens new tab but doesn’t reveal next button:
Qualtrics.SurveyEngine.addOnload(function() {
// Hide the Next button initially
jQuery("#NextButton").hide();
// Attach a click event handler to the "Take Exercise" link
jQuery("#"+this.questionId+" a").click(function(event){
// Prevent the default link behavior
event.preventDefault();
// Set the Embedded Data value to Yes
Qualtrics.SurveyEngine.setEmbeddedData('LinkClicked', 'Yes');
// Open the link in a new tab
window.open('#link', '_blank');
});
});
Qualtrics.SurveyEngine.addOnReady(function() {
// Hide the Next button if LinkClicked is not equal to Yes
if (Qualtrics.SurveyEngine.getEmbeddedData('LinkClicked') !== 'Yes') {
jQuery("#NextButton").hide();
}
});