Tracking when an external link is clicked in Qualtrics?

ε祈祈猫儿з 提交于 2019-12-02 07:09:35

问题


Based on these instructions- Javascript code to record click on link to PDF - Qualtrics

I set up the link (with unique ID of human) in the question, I added the javascript to the javascript panel in the question but I am not sure what to add into the survey flow section.

This is what I have now and it doesn't seem to be working:

1=human

Thanks

Here is my link I need to track-

<a href="http://vpf2.cise.ufl.edu/Classic/Interaction/Prototype/23341" id="human" target="_blank">Test Link</a>

and here is the javascript I put with the question.

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

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

});

回答1:


The variable a is getting undefined, since the selector is searching for the tag <human>.

Try this: $('#human') to select the element by it's ID.

[EDIT]

And use to bind the click event:

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



回答2:


Try this:

In survey flow:

human = 0

Question html:

<a href="http://vpf2.cise.ufl.edu/Classic/Interaction/Prototype/22318?username=" id="human" target="_blank">Click here</a>

JavaScript:

Qualtrics.SurveyEngine.addOnload(function()
{
       $('human').observe('click',function(event) {
            Qualtrics.SurveyEngine.setEmbeddedData("human", "1"); 
       });
});

Note: In Qualtrics $ refers to prototypejs, not jquery.



来源:https://stackoverflow.com/questions/36379227/tracking-when-an-external-link-is-clicked-in-qualtrics

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