Created
January 8, 2012 14:02
-
-
Save dominikzogg/1578450 to your computer and use it in GitHub Desktop.
Load Contao Piwik tracking after window load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- indexer::stop --> | |
<!-- Piwik --> | |
<script type="text/javascript"> | |
<!--//--><![CDATA[//><!-- | |
window.addEvent('load', function() | |
{ | |
var pkBaseURL = 'https:' == document.location.protocol ? 'https://www.<domain>.<tld>/' : 'http://www.<domain>.<tld>/'; | |
Asset.javascript(pkBaseURL + 'piwik.js', | |
{ | |
onLoad: function(){ | |
try { | |
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', <id>); | |
piwikTracker.trackPageView(); | |
piwikTracker.enableLinkTracking(); | |
} catch( err ) {} | |
} | |
}); | |
}); | |
//--><!]]> | |
</script> | |
<!-- End Piwik Tag --> | |
<!-- indexer::continue --> |
the mootools window.addEvent('load', function(){}); loads not on dom ready, it loads after all images are loaded to, so theres no usable time tracking if you include it this way.
True, that's why I was asking. Btw. this not only the case for mootools but for window.onload in general (load event fires at the end of the document loading process, cf. MDN).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm wondering if that negatively affects Piwik's time counters (window.onload is set off from loading piwik.js if not done like this)?