top of page
bottom of page
function sendHotjarVisibilityEvent(state) { if (window.hj) { hj('event', state); // example: 'page_visible' or 'page_hidden' } } document.addEventListener('visibilitychange', () => { if (document.hidden) { sendHotjarVisibilityEvent('page_hidden'); } else { sendHotjarVisibilityEvent('page_visible'); } });