Track Hyperlink Selection Order | XM Community
Skip to main content

Hello,
I've noticed several posts about scripting in JQuery for embedded variables to show a 1 if a hyperlink is selected and a 0 if it is not. I was able to get that coded and working but I have a different question.
If within a block, there are several hyperlinks (i.e., 4), can you output the order of selected hyperlinks by the participant? So for instance, lets say there are Hyperlink1, Hyperlink2, Hyperlink3, Hyperlink4 within the block. The participant selects Hyperlink4 then Hyperlink2.
The output would show 1's for Hyperlink2 and Hyperlink4 and 0's for Hyperlink1 and Hyperlink3 based on selecting the hyperlink. But also, the output would show the order or selection - (1) Hyperlink4 (2) Hyerlink2.
Does anyone know if this can be done in Qualtrics?
Thanks so much in advance.
V/r,
J

Hi there, this can be put in place with JavaScript by creating a variable and appending text to it each time the links are clicked. The below example uses 3 hyperlinks and also includes timestamps for the clicks. The timestamps aren't needed, but you could use these fields later to see how far a part each click was if you wanted.
First, create the following Embedded Data fields at the top of the survey flow and set their value equal to 0:

  • clicked1, clicked2, clicked3, clickedtime1, clickedtime2, clickedtime3,

Also create the field of 'order' but don't set its value to anything.
Then, add the hyperlinks to the QuestionText using the Rich Content Editor. Make sure they have IDs that the JS will reference, something like the below:
The link1: Click here

The link2: Click here

The link3: Click here

Finally, add the below code to the question's JavaScript in the OnReady section:
var order = "${e://Field/order}";

jQuery('#extLink1').click(function(event) {
var timestamp1 = new Date().toLocaleString();
order+='extLink1';
    Qualtrics.SurveyEngine.setEmbeddedData("clicked1", "1");
Qualtrics.SurveyEngine.setEmbeddedData("clickedtime1",timestamp1);
Qualtrics.SurveyEngine.setEmbeddedData("order",order);
  });

jQuery('#extLink2').click(function(event) {
var timestamp2 = new Date().toLocaleString();
order+='extLink2';
    Qualtrics.SurveyEngine.setEmbeddedData("clicked2", "1");
Qualtrics.SurveyEngine.setEmbeddedData("clickedtime2",timestamp2);
Qualtrics.SurveyEngine.setEmbeddedData("order",order);
  });

jQuery('#extLink3').click(function(event) {
var timestamp3 = new Date().toLocaleString();
order+='extLink3';
    Qualtrics.SurveyEngine.setEmbeddedData("clicked3", "1");
Qualtrics.SurveyEngine.setEmbeddedData("clickedtime3",timestamp3);
Qualtrics.SurveyEngine.setEmbeddedData("order",order);
  });


Leave a Reply