Qualtrics.SurveyEngine.addOnload(function(){
var timer = document.createElement("div");
timer.className = "timer";
timer.id = "timer_1";
timer.innerHTML = "time: 00:00";
// timepassed is the measure of how long a respondent stays on the given page
var timepassed = 0;
var myTimer;
function startTimer() {
myTimer = setInterval(increaseSeconds, 1000);
}
function increaseSeconds() {
timepassed++;
document.getElementById("timer_1").innerHTML="time: " + formatTime(timepassed);
}
function formatTime(time) {
const minutes = Math.floor(time / 60);
let seconds = time % 60;
if(seconds < 10) {
seconds = `0${seconds}`;
}
return `${minutes}:${seconds}`;
}
display = document.querySelector('#time');
startTimer();
$('NextButton').onclick = function (event) {
//stop timer
clearInterval(myTimer);
//timepassed variable at this point should contain how long the respondent has spent on this page.
};
});
Qualtrics.SurveyEngine.addOnReady(function(){});
Qualtrics.SurveyEngine.addOnUnload(function()
{
var var1 = this.getChoiceValue(1)
Qualtrics.SurveyEngine.setEmbeddedData('fruit1', var1);
var var2 = this.getChoiceValue(3)
Qualtrics.SurveyEngine.setEmbeddedData('fruit2', var2);
var timeSpentOnPage = this.timepassed;
});
I'm trying to create a timer that measures how long a respondent stays on a given survey page, and also make the timer visible on the page as well. I couldn't find the HTML editor for each question/page, but with a bit of digging around the internet and this forum, (I think) I found a way to use HTML from js. Unfortunately, when I actually preview the survey, I don't see my timer anywhere (and hence can't tell if my timer actually works at all, either). Could someone help me find what the problem might be?
JS timer not visible on survey page
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
