Website changed and tracking stopped working

Hi All,

We are running the free Piwik 3.0.4 and recently changed our website from Drupal 6 to 7. With that, the entire subpage tree changed and apparently, no page visits are any longer recorded in Piwik because it expects invalid URLs, sub-pages that existed in D6 but not in Drupal D7. I’ve checked that the tracking code is correctly implemented, all good and this cannot be the cause of the issue. I do think that if there would be an easy way to tell our Piwik to re-scan the website’s new directory structure, it would resume tracking. If this doesn’t exist, can I add a 2nd page to track the new website?

Alex

Hi,

I think you are misunderstanding how piwik works.

Piwik doesn’t know or care about the structure of the site. It just reports the URL the visitor requests.

Is it possible you have changed the HTTPS configuration on the new website?

Can you check your browser’s developer tools and see if there are errors in the console?

Hi Lukas, thanks for your reply. Good to know that Piwik does not care about an older structure. The website does have a section which is secured via a new SSL-certificate, this is indeed the case, however I then do not understand why that would also trigger that public content would not report any stats. Currently our piwik installation reports 0 visitors also for public pages, even though the tracking code is implemented. I had a view in the debugger using Firefox and it does list one thing that makes me wonder if it’s related: _"_paq.push() was used but Piwik tracker was not initialized before the piwik.js file was loaded. Make sure to configure the tracker via _paq.push before loading piwik.js. Alternatively, you can create a tracker via Piwik.addTracker() manually and then use paq.push but it may not fully work as tracker methods may not be executed in the correct order.",c"

Could that be it?

Alex

Hi,

That sounds like there is an issue with the tracking code.
Can you check if it is inserted correctly and not just <script type="text/javascript" src="//piwik.example/piwik.js"></script>

Or can you send me an message with an link to your website?

I looked through the source of your website and found that the tracking code you are using is kind of odd:

<script>
  (function($, Drupal) {
    Drupal.behaviors.piwik = {
      attach: function(context, settings) {
        if (Drupal.eu_cookie_compliance.getCurrentStatus() == 2) {
          var _paq = _paq || [];
          var u = (("https:" == document.location.protocol) ? "https://piwik.bonn-is.de/" : "http://piwik.bonn-is.de/");
          _paq.push(["setSiteId", 1]);
          _paq.push(["setTrackerUrl", u + "piwik.php"]);
          _paq.push(["setDoNotTrack", 1]);
          if (Drupal.eu_cookie_compliance.getCurrentStatus() == 0) {
            _paq.push(['disableCookies']);
          }
          ;_paq.push(["trackPageView"]);
          _paq.push(["setIgnoreClasses", ["no-tracking", "colorbox"]]);
          _paq.push(["enableLinkTracking"]);
          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);
        }
      }
    };
  })(jQuery, Drupal);
</script>

Drupal.eu_cookie_compliance.getCurrentStatus() seems to get the current status of the We use cookies on this site to enhance your user experience-Toolbar.
In my test it returns null before it is accepted and and 2 after I clicked OK.

If I now understand that tracking code correctly Piwik is only included and if Drupal.eu_cookie_compliance.getCurrentStatus() == 2 or in other words if the visitor has accepted the cookie toolbar.

And I can imagine as it is quite hard to see, that nearly all your visitors don’t click on the OK button and as a result don’t get the piwik tracking code.

BTW: Your website takes 16 Seconds, 15 MB, 160 Requests and lets my notebook get really hot while loading.