check if respondent is on survey page | XM Community
Skip to main content

I want to create a variable that would allow me record whether the subject navigated away from the survey page. I have the following code, but for some reason it does not work as I am hoping.. any ideas on how i can get it to work? Thanks so much!
var onpage=0;
function checkPageFocus() {
  if (document.hasFocus()==true) {
  }
  else {
    onpage=1;
Qualtrics.SurveyEngine.setEmbeddedData("onpage", onpage);
  }
}
setInterval(checkPageFocus, 1000);

Be the first to reply!

Leave a Reply