I'm using Leaflet to insert a map into Qualtrics. For one of my markers, I have it set up so that (1) a popup appears with a mouse hover and (2) clicking on the popup continues on to the next page in the experiment:
marker1.on('mouseover', function (e) {
this.openPopup();
this.getPopup()._contentNode.onclick = function () {
document.querySelector("#NextButton").click();
Qualtrics.SurveyEngine.setEmbeddedData("home", "one");
};
});
Is it also possible to use embedded data to also record when the mouse hover occurs with a time stamp? If so, how?
Use Date.now() and set it as an embedded variable.
https://www.qualtrics.com/community/discussion/comment/35007#Comment_35007This gets be part way there, but where does it go in my code. Like this?
marker1.on('mouseover', function (e) {
this.openPopup(
Qualtrics.SurveyEngine.setEmbeddedData("timestamp", "Date.now()");
);
this.getPopup()._contentNode.onclick = function () {
document.querySelector("#NextButton").click();
Qualtrics.SurveyEngine.setEmbeddedData("home", "one");
};
});
marker1.on('mouseover', function (e) {
this.openPopup();
Qualtrics.SurveyEngine.setEmbeddedData("timestamp", Date.now());
this.getPopup()._contentNode.onclick = function () {
document.querySelector("#NextButton").click();
Qualtrics.SurveyEngine.setEmbeddedData("home", "one");
};
});
https://www.qualtrics.com/community/discussion/comment/35010#Comment_35010This worked perfectly. Do you have any ideas on how I can handle the fact that people could hover multiple times on marker 1? That is, how can I record multiple instances of this hovering behavior in my survey?
var times = 0;
marker1.on("mouseover", function (e) {
this.openPopup();
times++;
Qualtrics.SurveyEngine.setEmbeddedData("timestamp" + times, Date.now());
this.getPopup()._contentNode.onclick = function () {
document.querySelector("#NextButton").click();
Qualtrics.SurveyEngine.setEmbeddedData("home", "one");
};
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.