Count number of times respondent leaves survey window/tab | XM Community
Question

Count number of times respondent leaves survey window/tab

  • 13 April 2020
  • 1 reply
  • 108 views

Badge

Hi everyone,
In my survey, I'm trying to include a counter that tracks the number of time that the respondent leaves the survey window/tab during the course of the whole survey--in other words, the number of times that the survey window/tab is either hidden or blurred because they have clicked on another window/tab. I've tried to make this work by creating an Embedded Data object in Survey Flow called offpagecount with an initial value of 0, and then adding the following code to the survey Header (Look and Feel --> General --> Header --> Source button):



Based on the alerts, the survey does recognize each of the visibilitychange and onblur events as they occur. However, the Embedded Data doesn't seem to be getting updated each time one of these events happens. It only seems to update by a max of 1 per page of the survey. So if I go offpage 5 times on page 1 of the survey, offpagecount will stay as 0 for the whole first page, and become 1 when I get to page 2 (though if I don't go offpage at all on page 1, offpagecount = 0 on both page 1 and page 2). Any help would be greatly appreciated!


1 reply

Hello teammiele I'm actually looking for similar code to see if survey responders are cheating on a task I've set out for them. Were you able to resolve this issue?

Leave a Reply