WordPress: Uncaught ReferenceError: piwikTracker is not defined

I have a custom tracking JavaScript file that tags certain DOM elements’ clicks and records them via the piwikTracker function call.

The problem is that the WP scripts are loaded in the header and the piwik script is apparently loaded in the footer.

I specified that my JavaScript wait for the ready handler but my script still does not load when I enqueue the script with a dependency on the script ‘wp-piwik’.

If I remove the dependency then I get this error in Chrome.

So am I even loading piwik? How do I load the tracking script on each page (I though it was by default)? and what is the alias of the script so I can specify the dependency?

If the piwik tracking script is not being loaded, would I have to copy and paste Piwik’s tracking code into it’s own script and load that like I would any other JavaScript file? I figured the plugin handled that for me:

http://piwik.org/docs/javascript-tracking/#toc-where-can-i-find-the-piwik-tracking-code

You can put the script above or split it in 2 sections: the first one to load the JS and initiates the tracker, then in the footer call trackPageView()

sorry there is no doc AFAIK about this, but if you figure it out please commment here I will add the doc!

Are you saying I need to manually load the script?

I don’t see why it works in IE but not Chrome without loading any custom script?

I also find it odd that the only code for wp-piwik.js (with alias ‘wp-piwik’) is this:


function datelink(strPage,strDate,intSite) {
	window.location.href='index.php?page='+strPage+'&date='+strDate+'&wpmu_show_stats='+intSite;
}