Been using piwik for a few years, always upgraded when it tells me to, no problems… until this time.
Former code, up through 1.10 (I trimmed back the part that checks your protocol, because I’m strictly http):
<script type = "text/javascript">
try
{
var piwikTracker = Piwik.getTracker("http://www.example.com/piwik/piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
}
catch( err ) {}
</script>
<noscript>
<p><img src = "/piwik/piwik.php?idsite=1" style = "border: 0" alt = ""></p>
</noscript>
Code I am now told to use (I left the protocol-checking part in place just to ensure I hadn’t misplaced a parenthesis):
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.example.com/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "1"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript>
<img src="http://www.example.com/piwik/index.php?idsite=1&rec=1" style="border:0" alt="" />
</noscript>
(Yes, index.php rather than piwik.php. Um, isn’t index.php the view-report page?)
This leads to a flurry of “file does not exist” errors as it looks for www.example.com/piwik.js. Fixed that by adding piwik/ to path in both places… but it STILL can’t find the php file. Or rather, it doesn’t seem to understand that it’s supposed to look for it. Instead my logs show a stream of
GET /directory/filename.html?action_name={et cetera}
That is, it’s appending the piwik query string to the current filename-- whatever it is-- instead of to /piwik/piwik.php
The /piwik/ directory is where it always was. Its assorted files have up-to-the-minute timestamps; there’s no new stuff flopping around loose in the root.
Each file’s tracking code is where it always was, part of an included footer. There’s also a line in each head section
<script type = "text/javascript" src = "/piwik/piwik.js"></script>
This goes back several piwik releases so I’m not clear whether it’s still needed but it can’t be doing any harm.
What on earth is its problem? No new data has come in since I upgraded.