- Published on
WP-Piwik and disabled index-file.names
WP-Piwik is a really cool plugin to connect your wordpress-site with Piwik and I am using it on all my installations. But as I moved Piwik to a new server the plugin refused to generate the proper JavaScript-code. WP-Piwik could connect to my Piwik-server but the URLs in the script were wrong, as you can see here:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://mydomain.de/" : "http://mydomain.de/");
document.write(unescape("<script src='" + pkBaseURL + "piwik.js' type='text/javascript'></script>"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://mydomain.de/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
Piwik is actually installed in a subdirectory “/piwik” on mydomain.de. The cause for this problem here is, that I was running lighttpd and had disabled any file-index.names on that specific domain. Within the installation of WP-Piwik the default setting “mydomain.de/piwik” is not working, but the plugin accepts “mydomain.de/piwik/index.php”. At the first moment it looks like the plugin is doing its job, but the generated JavaScript-Code is missing the subdirectory in pkBaseURL. In this case, tracking simply doesn’t work.
Sure, it is not an major issue nor is it happening very often but when you’re in this situation it’s pretty hard to find the bug. I’ve already contacted the developer of WP-Piwik and as a workaround for now I can only suggest to enable “index.php” in file-index.names of your Piwik-installation.
Edit: I've spoken to the author of WP-Piwik André Bräckling and he fixed the issue (which was more Piwik-related than a actual bug in the plugin) in not more than 6 days! Revision 0.8.8 is the fixed one and is already in the wordpress plugin directory. Thanks André, you do a great job!