Javascript code to record click on link to PDF - Qualtrics

放肆的年华 提交于 2019-11-30 09:30:04

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31013065/javascript-code-to-record-click-on-link-to-pdf-qualtrics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!