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 --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).