This page describes how you can record if the participant leaves the questionnaire’s browser tab – for example, if he opens a new tab to google the answer to a knowledge question.
Important: This function records every leaving of the browser tab –– not only the change of a tab but also a switch to a chat program, to the email-client etc.
Important: This function uses JavaScript. If the variable does not contain any value, the participant had deactivated JavaScript.
Advice: The code is being executed in the particpant’s browser. With the necessary technical knowledge the user can manipulate the value.
Tip: Another valuable information about whether the participant has done something else while answering your questionnaire may be the dwell time of a page that can be downloaded with the dataset.
blurCount("IV01_01")
change IV01_01
to the ID of your internal variable (item).<script type="text/javascript"> <!-- function blurCount(inputID) { var input = document.getElementById(inputID); if (!input) { alert("Error: the internal variable" + inputID + " is not available on this page!“); return; } // Initalize (value: 0) if (isNaN(parseInt(input.value))) { input.value = 0; } // Call this function when the window is being left function countBlur(evt) { var val = parseInt(input.value); input.value = val + 1; } // activate counter for every leaving of the page SoSciTools.attachEvent(window, "blur", countBlur); } // Activate counter blurCount("IV01_01"); // --> </script>
Tip: When creating your questionnaire, you can change the question type of the internal variable to an open text input to see the counter live. Set it back to an internal variable when starting the field phase of your survey.
Advice: This measurement is valid for one single page only — the one that contains the internal variable and the code. If you would like to observe more than one pages, create additional internal variables and add them together with this code on all pages (make sure to change the variable in the code each time).