Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Mandating clicking on the Embedded Link in the Survey + timestamp for the click

Gauri
Gauri United KingdomCommunity Member Qubie ✭
edited July 8 in Custom Code

Hi

I have embedded a link in my survey that I want all respondents to click on. I need help with the Java Script code for three functions, listed below. I would really appreciate any help with this! Thank you so much.

  1. I want to prevent the Next Button from showing until the participant has clicked on the embedded link. This is just a way to ensure that the participant clicks on the link and doesn't skip to the next page without doing that.
  2. I want the page to automatically move on to the next one as soon as the participant clicks on the link. This is to ensure that they don't click on the link more than once.
  3. I want a timestamp for when the participant clicks on the embedded link.

This is what I have so far: The command for it to tell me when the respondent clicks on the link works. (t1shared=1 if respondent clicks). But the Hide Next Button command isn't working.


Qualtrics.SurveyEngine.addOnload(function()

{ jQuery("#extLink").click(function(event) {

  Qualtrics.SurveyEngine.setEmbeddedData("t1.shared","1"); });

});

Qualtrics.SurveyEngine.addOnReady(function()

{ var qobj = this;

qobj.hideNextButton();

jQuery("#extLink").click(function(event) { qobj.showNextButton(); }) 

});

Qualtrics.SurveyEngine.addOnUnload(function()

{/*Place your JavaScript here to run when the page is unloaded*/}

Answers

  • ChiragK
    ChiragK GUJARATCommunity Member Guru ✭✭

    Hello, Create embedded variable "timestamp" and try this code

    Qualtrics.SurveyEngine.addOnReady(function() {
        var qobj = this;
        qobj.hideNextButton();
        jQuery("#extLink").click(function(event) {
    	Qualtrics.SurveyEngine.setEmbeddedData("t1.shared", "1");
    	Qualtrics.SurveyEngine.setEmbeddedData("timestamp", new Date());
    	qobj.clickNextButton(); 
        }) ;
    });
    
  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭

    Thanks, I will just try this. When I add "timestamp" as a variable, do I set a value for it?

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭


    Hello

    Using your code I have been able to make the hide.Next Button and the click.Next Button commands work. Thanks.

    But now Qualtrics isn't recording "1" for participants who clicked on the link. In fact, irrespective of whether people clicked or not, I get a value of "0" when I export the data. How can I fix that?

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭

    Hello

    Using your code I have been able to make the hide.Next Button and the click.Next Button commands work. Thanks.

    But now Qualtrics isn't recording "1" for participants who clicked on the link. In fact, irrespective of whether people clicked or not, I get a value of "0" when I export the data (my embedded variable t2.shared has set value to 0).

    This is important for me because I have two links to be clicked. On the same page, there are two questions, each with a link. I am asking participants to click on any one of the two. I want Qualtrics to tell me which link they clicked on. Here is what I have so far in the code:



  • ChiragK
    ChiragK GUJARATCommunity Member Guru ✭✭

    Hi, Please confirm if you're setting up embedded field at the top of survey flow.