Track whether a link is clicked in qualtrics even a respondent leaves for the opened new page

daniel_navarrodaniel_navarro BarcelonaCommunity Member Qubie ✭

Track whether a link is clicked in qualtrics even a respondent leaves for the opened new page

Dear all:

I have a question. In my survey, I have an external link inserted. I want a value of 1 is recorded if the link is clicked; otherwise a value of 0 is recorded. I followed a instruction given on a website: https://stackoverflow.com/questions/38225021/tracking-when-an-external-link-is-clicked-in-qualtrics-with-javascript. It works very well if a respondent's response is recorded as complete. But suppose a respondent clicks the link and then leaves for the new page and never comes back, then his response is recorded as response in progress. And when I check his response, a value of 0 is recorded even though he clicks the link. Is there a way to deal with this? Thanks.

Tagged:

Best Answer

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭
    Accepted Answer

    @daniel_navarro,

    I'm the author of the Stackoverflow post you cited. Embedded variables don't get saved on the Qualtrics server until the page is submitted. So, you just need to add a line to the script to click the Next Button. I've updated it to use jQuery instead of prototypejs:

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

Answers

  • MsIreenMsIreen FinlandCommunity Member, XMPN Member Superuser ✭✭✭✭

    @daniel_navarro Did you put the embedded data in the survey flow in the very beginning?

  • daniel_navarrodaniel_navarro BarcelonaCommunity Member Qubie ✭

    @TomG ,
    Thanks a lot. Do you mean I need to put the codes above as Javascript of the descriptive text in Qualtrics? And after I attach the new code, the qualtrics page will go to next page automatically after the link is clicked?

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭

    @daniel_navarro said:
    @TomG ,
    Thanks a lot. Do you mean I need to put the codes above as Javascript of the descriptive text in Qualtrics? And after I attach the new code, the qualtrics page will go to next page automatically after the link is clicked?

    Yes and yes

  • kobi_mizrahikobi_mizrahi Community Member Qubie ✭
    edited December 2019

    @TomG
    I am using the same javascript concept of id you show in that stackoverflow post, but to a different aim - I want to check how many times each answer choice in a multiple choice question is being clicked. I gave an id to the text in the following way:

    choice_text

    , and the code was:

    **var clicked = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clicked_choice"));

    $('choice_name').on('click', function(name, event) {
    clicked++
    Qualtrics.SurveyEngine.setEmbeddedData('clicked_choice',clicked);
    });
    **
    (There is a embedded data field called clicked_choice which is initially set to 0)

    This almost works, the only problem is that if participants click on the answer choice box but not on the text itself, the code doesn't count it (so for some participants, it shows eventually that none of the choices was clicked and the participant moved forward, even though I force response on the question (and I get an answer in the data). For some of my answer choices, the choice text is very small relative to the size of the box, so there is very little chance that the participant will click on the text itself.

    Thanks in advance!

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭

    How did you give an id to choice_text and what is choice_name?

    MC questions work with labels where the label includes the choice text associated with a checkbox (multi-select) or radio button (single select). Clicking the label will fire the checkbox/radio input click event. So, you should attach your event listener to the checkbox/radio input element.

  • kobi_mizrahikobi_mizrahi Community Member Qubie ✭
    edited December 2019

    @TomG
    Thanks for answering so quickly!

    Sorry, I put in the html text so you couldn't see it. Here it is snipped (This is the text I put into the selection choice, in normal view only "choice_name" is seen):

    (So, you can see that choice_name is the id I gave to the paragraph)

    It's a single select, can you please show me how do I refer to the radio button? (I am just now learning to use html+JS through Qualtrics.

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭

    There are a number of different ways to do it. To simplify, let's say the choiceid of the choice you are interested in is 1. Then:

    jQuery("#"+this.questionId+" input[choiceid=1]").click(function() { ... etc...
    
  • kobi_mizrahikobi_mizrahi Community Member Qubie ✭

    @TomG

    Thanks a lot, works like magic! (or like coding)

    You Tom, are the king of this forum, and probably of many other forums as well.

  • tennysonwutennysonwu NetherlandsCommunity Member Qubie ✭

    @TomG

    I'm very new to Qualtrics and Javascript, and have tried to implement your Javascript code, so please excuse the silly sounding question.

    Where does the result of the embedded variable get stored after the respondent submits their survey responses?

    I do not seem to find anywhere in their individual report that shows the "clicked" variable.

    Should it be there and have I perhaps not implemented your solution correctly?

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭

    @tennysonwu - Did you define "clicked" in the survey flow prior to the block that contains the link?

  • tennysonwutennysonwu NetherlandsCommunity Member Qubie ✭

    Hi again @TomG

    Thanks for getting back to me so quickly. I think I defined "clicked" prior. (I called it "clicked1" since I plan on tracking several links out of my survey).

    Question 7 is where I have my link:

    I have included the "clicked" variable in question 6 just before question 7:

    and I have also included the same variable in the last question of the previous block of questions:

    What am I doing wrong?


    Thanks again for your help

    Tennyson

  • TomGTomG Raleigh, NCCommunity Member Wizard ✭✭✭✭✭
    edited May 15

    Your jQuery selector is wrong. It isn't the url. Give the link an id in your html:

    <a id="click1" href="https://example.com/page.html" target="_blank">Link text</a>
    

    Then your jQuery is:

    jQuery("#click1").click( ...
    

    Also, you need to define the embedded data field 'click1' in the Survey Flow, not in JS.

Sign In to Comment