-1

I am working on a survey in Qualtrics. In this survey, I direct respondents to a link at the end of the survey.

I want to record whether or not respondents click on the link. If they click on the link, then I would like for the survey to automatically click the next button (thereby finishing the survey).

I've tried the code in the following post on Stack Overflow and the follow-up post on Qualtrics forum, without much luck.

Currently, I've created an embedded field called ClickLink which is placed at the beginning of the survey and is set to zero

The HTML of the Qualtrics questions is:

This is a link: <a href="http://www.google.com" target="_blank" id="Link">Click here</a>

The javascript for the question's behavior follows the Qualtrics forum and is:

Qualtrics.SurveyEngine.addOnload(function() {
    jQuery('Link').click(function(event) {
        Qualtrics.SurveyEngine.setEmbeddedData("ClickLink", "1");
        jQuery("#NextButton").click();
    });
});

I would greatly appreciate any assistance in getting the survey to function as desired. Thank You!

Sharif Amlani
  • 1,138
  • 1
  • 11
  • 25

1 Answers1

1

You jQuery 'Link' selector is incorrect. It should have a # in front of the id:

Qualtrics.SurveyEngine.addOnload(function() {
    jQuery('#Link').click(function(event) {
        Qualtrics.SurveyEngine.setEmbeddedData("ClickLink", "1");
        jQuery("#NextButton").click();
    });
}); 
T. Gibbons
  • 4,919
  • 2
  • 15
  • 32