问题
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