I would recommend trying the visibilitychange event instead of 'pagehide' and designing your stats update to handle that it may not be the final thing and may have a subsequent call where you would update the stats again (for example, a user may have just minimized the window, then raised it again, then closed it - that would generate 3 visibilitychange events: hidden, shown, then hidden again).