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

check if respondent is on survey page

  • May 7, 2020
  • 0 replies
  • 11 views

Forum|alt.badge.img+6
  • Level 2 ●●

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);