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.

Did respondents click on the embedded link or not?

Gauri
Gauri United KingdomCommunity Member Qubie ✭

Hello

In my survey I have embedded two links. 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 of the two links they clicked on. I have a Javacript code for showing "1" if the participant clicks on the link, but Qualtrics isn't recording if the link was clicked. 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).

It might be because the "click.NextButton" command is interfering with it. I need that command in too because I want the survey to automatically be taken to the next if the page if they have clicked on any one of the links.

Please help!

Here is what I have so far in the code:


Tagged:

Answers

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    Use the following code in the click function of the link;

    if(jQuery('#extLink1').data('clicked', true))

    {

    //Code to check console if inside and then click next button

    }

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭


    Do I replace any part of the original code with this or add this to the original code?

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭


    Hello. I tried it and unfortunately it did not work. This is what my code looks like:

    Where am I going wrong? It still shows "0" for both links even though one of them was surely clicked.


    Qualtrics.SurveyEngine.addOnload(function()

    {

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

    Qualtrics.SurveyEngine.setEmbeddedData("t2.sharedvaccine", "1");

     });

    });

    Qualtrics.SurveyEngine.addOnReady(function()

    {

      var qobj2 = this;

      qobj2.hideNextButton();

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

    qobj2.clickNextButton(); 

    if(jQuery('#extLink').data('clicked', true))

    {//Code to check console if inside and then click next button

    }

      });

    });

    Qualtrics.SurveyEngine.addOnUnload(function()

    {

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

    });

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    Use this code for "on Next button" click and call in "onReady" .


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

    if(jQuery('#extLink').data('clicked', true))

    {

    Qualtrics.SurveyEngine.setEmbeddedData("t2.sharedvaccine", "1");

    }


     });

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭


    Thanks for the quick reply! Is it possible for you to copy my full code and edit it and post it here for me to better understand where to fit it? I think I might be getting confused about it's placement.

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    It should look like below; Hope this helps though not sure about hidenextbutton and clicknextbutton :')


    Qualtrics.SurveyEngine.addOnload(function()

    {

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

    if(jQuery('#extLink').data('clicked', true))

    {

    Qualtrics.SurveyEngine.setEmbeddedData("t2.sharedvaccine", "1");

    }

     });

    });

    Qualtrics.SurveyEngine.addOnReady(function()

    {

     var qobj2 = this;

     qobj2.hideNextButton();

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

    qobj2.clickNextButton(); 

    if(jQuery('#extLink').data('clicked', true))

    {//Code to check console if inside and then click next button

    console.log('Yes Clicked')

    jQuery("#NextButton").click();

    }

     });

    });

    Qualtrics.SurveyEngine.addOnUnload(function()

    {

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

    });

  • Gauri
    Gauri United KingdomCommunity Member Qubie ✭


    Thank you Rahul. But it still doesn't work. Qualtrics is showing "0" even when people click on the link. :(

  • grahulp5
    grahulp5 IndiaCommunity Member Guru ✭✭

    Try console log and see whether the if logic is getting executed or not. That should let you know if the error is with the logic or setting the embedded data.