Piwik JavaScript Error: ReferenceError: Piwik is not defined

Hello,
i have 3 sites where I tried to include the Piwik JavaScript, but it works only on one site… style_emoticons/<#EMO_DIR#>/sad.gif

I added a alert(err) to the catch block and got the info: “ReferenceError: Piwik is not defined”

This are the tree sites:

  • [www.cvjm-nuernberg.de[/url] (works)
  • [url=http://blog.cvjm-nuernberg.de]blog.cvjm-nuernberg.de[/url] (does not work)
  • [url=http://galerie.cvjm-nuernberg.de]galerie.cvjm-nuernberg.de](http://www.cvjm-nuernberg.de)(does not work)

I would be so happy if someone who has more knowledge in JavaScript than me, could help me with this problem.

Thanks in advance!
Ciao!
Stefan

[quote=habakuk @ Jun 28 2009, 08:22 PM]Hello,
i have 3 sites where I tried to include the Piwik JavaScript, but it works only on one site… style_emoticons/<#EMO_DIR#>/sad.gif[/quote]

Now it looks like it would work on all sites; but i didn’t chnage anything since yesterday…

Ciao!
Stefan

Stefan,

Since your sites aren’t available via https, you should static load piwik.js. This is also recommended if your pages are served as XHTML.

<!-- Piwik -->
<script type="text/javascript" src="http://statistik.trumpkin.de/piwik.js></script>
<script type="text/javascript">
try {
  var pkBaseURL = "http://statistik.trumpkin.de/";
  var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);
  piwikTracker.setDocumentTitle("Blog/" + document.URL.substr(30));
  piwikTracker.trackPageView();
  piwikTracker.enableLinkTracking();
} catch( err ) {
}
</script>
<!-- End Piwik Tag -->

Hi,

I know that this thread is a little rusty. But I recently faced the same problem as habakuk (new domain, same settings as working domain, but error: Piwik is not defined) and after two hours reinstalling, changing javascript etc. I found the solution:

Adblock plus

I did’nt have the new domain in my whitelist and so Adblock plus stopped piwik from loading, thus throwing the error. After whitelisting the new domain, everything ran smoothly.

best regards,
Oliver

Anyone know how to take care of this in a WordPress environment?

I’m not sure if I should enqueue piwik.js separately or if the plugin already takes care of that (What are the downsides to enqueueing a script twice?)

Also, there’s a piwik.js on the Piwik folder and also in the Piwik/js folder. Which one is being queued?

Thanks