New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Events send on Beforeunload is sent twice in Chrome #13577
Comments
Are you sure the event is triggered twice and the user for example didn't have the site open in two tabs and closed both? |
yes. |
this is a small hotfix - creating a state varialble - but not really ideal. <script type="text/javascript">
var beforeunloadFired = false;
function onExit() {
if (beforeunloadFired === false) {
window._paq.push(['trackEvent', "MyExitCategory", "MyExitAction", "web", 1]);
}
window.removeEventListener("beforeunload", onExit);
beforeunloadFired = true;
}
window.addEventListener('beforeunload', onExit)
</script> |
Are you sure the event is not fired twice? |
I think chrome might be firing it twice, but only one request is shown in the Network tab of Chrome Dev Tools. |
try it yourselves: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Track debug</title>
</head>
<body>
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u = 'https://demo.matomo.org';
u = u[u.length-1] === '/' ? u : u+'/';
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 44]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<script type="text/javascript">
function onExit() {
window._paq.push(['trackEvent', "MyExitCategory", "MyExitAction", "web", 1]);
window.removeEventListener("beforeunload", onExit);
}
window.addEventListener('beforeunload', onExit)
</script>
</body>
</html> |
It might be |
nope it works fine.
http://prntscr.com/l4l1yi |
I'm unable to reproduce the behaviour you noticed with: Chrome 69.0.3497.100 64 Bit on Ubuntu 14.04 |
interesting.. I have it on two different MacOS now. |
Hi @viezel Are you still able to reproduce this issue? if so can you please list again the steps to reproduce and browser you can reproduce this in? We'd really like to fix this issue if it's confirmed. Thanks! |
@mattab Just tested it again, and it seems fixed in newest version 👍 |
Matomo: 3.6.0
Browser: Chrome 69.0.3497.100
Results in:
(works in Firefox and Safari - but not in Chrome)
The
MyExitCategory
tracking event should only appear once.Is this a known bug?
The text was updated successfully, but these errors were encountered: