Skip to content

Instantly share code, notes, and snippets.

@dominikzogg
Created January 8, 2012 14:02
Show Gist options
  • Save dominikzogg/1578450 to your computer and use it in GitHub Desktop.
Save dominikzogg/1578450 to your computer and use it in GitHub Desktop.
Load Contao Piwik tracking after window load
<!-- 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 -->
@rocco
Copy link

rocco commented Feb 14, 2012

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