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
Fix outlinks and downloads are not tracked if document is already ready when piwik.js is loaded #9925
Conversation
@@ -4689,7 +4619,7 @@ if (typeof window.Piwik !== 'object') { | |||
} else if (windowAlias.addEventListener) { | |||
windowAlias.addEventListener('load', callback); | |||
} else if (windowAlias.attachEvent) { | |||
windowAlias.attachEvent('onLoad', callback); | |||
windowAlias.attachEvent('onload', callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be all lowercase actually. Possibly onLoad
works as well but lowercase is better
@@ -1068,10 +1068,6 @@ if (typeof window.Piwik !== 'object') { | |||
/* performance timing */ | |||
performanceAlias = windowAlias.performance || windowAlias.mozPerformance || windowAlias.msPerformance || windowAlias.webkitPerformance, | |||
|
|||
/* DOM Ready */ | |||
hasLoaded = false, | |||
registeredOnLoadHandlers = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registeredOnLoadHandlers + hasLoaded was only used for enableLinkTracking.
enableLinkTracking now uses existing trackCallbackOnReady
instead
} | ||
|
||
// sniff for older WebKit versions | ||
if ((new RegExp('WebKit')).test(navigatorAlias.userAgent)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally removed this one as I think it's not needed anymore and it can actually slow down all websites in WebKit for a while for quite a bit. It executed this every 10ms until websites was ready. As it sometimes takes a few seconds until a website is ready it executes this quite often.
@tsteur do you mind testing that it still works fine on IE10 / IE11 or so? Once confirmed +1 to merge this PR 👍 (note: there is currently a conflict, maybe you can remove the merged piwik.js from the commit) |
…eady ready when piwik.js is loaded
Tested on IE10 and works. Will merge and do afterwards some more tests |
I tested with IE8 and the callback works. I had some other problems tracking outlinks on IE8 but that was due to debugging mode likely. |
This should fix #9924
I tested it in Chrome and Firefox so far. If website was already loaded we will now execute the enableLinkTracking logic directly.