window.addEventListener('beforeunload', function(){ ga('send', 'event', 'Website', 'Unload', {transport: 'beacon', nonInteraction:true}); } );