4

For a survey experiment built in Qualtrics, I need to record whether respondents clicked on a hyperlink to a pdf document attached to one of my questions. I have set it up so that the pdf document opens in another tab. I am not proficient with Javasctript. What would be the simplest solution to record this information? Thank you in advance!

Another user asked a similar question about tracking hyperlink clicks to an external webpage, but I'm unsure if I can use a click thru when the document isn't exactly an external webpage.

Jlo236
  • 73
  • 4
  • 1
    Do you use Google Analytics? If so you can easily do this with [Event Tracking](https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide). – APAD1 Jun 23 '15 at 20:41
  • If you want to implement it yourself, you will have to create an API endpoint, where you will make an AJAX request, and in the back-end you will have a counter in a database that will be increased accordingly. However, as suggested by @APAD1, you could avoid all this by using Google analytics in your site. – Dimos Jun 23 '15 at 21:00

1 Answers1

3

There are 3 pieces to this process:

1: Set your link up with a specific ID for example:

<a id="myLink" href="http://communicus.com" target="_blank">Test Link</a>

2: For the question that you need this on, add the following JavaScript(adjust the ID and embedded data variable in the script as necessary):

Qualtrics.SurveyEngine.addOnload(function()
{
    var a = $("myLink"); //adjust ID here

      a.onclick = function() {
          Qualtrics.SurveyEngine.setEmbeddedData("clicked", 1); //adjust embedded data variable here
      }

});

3: Add the embedded data variable, to match your JavaScript, in the survey flow section. Make sure that it exists in survey flow prior to the block your question resides in.

This will let you track those who clicked the link in a Qualtrics variable.

Anthony Rivas
  • 952
  • 13
  • 21
  • Not a problem, hope it helps. If it works, I'd appreciate you marking my answer as accepted for future people seeking information. – Anthony Rivas Jun 24 '15 at 22:19
  • Hi Anthony. Thank you for this answer. However, I am uncertain about the third step of this process. What do you mean by adding the embedded data in the survey flow section? Could you show a picture to demonstrate this? Thanks! – juanjedi Mar 29 '21 at 17:57