Support » Plugin: WP-Piwik » Generated tracking code incorrect

  • I’m running multiple sites in a WP multisite setup. Upgrading to the latest wp-piwik broke the generation of the correct tracking code for my sites. I noticed 2 things:

    1. the piwik url no longer contains my virtual hostname, but the IP-number of my server;
    2. the setSiteId points to the wrong site;

    Here’s what wp-piwik generated for me:

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['setRequestMethod', 'POST']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://"
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', 2]);
        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);
    <!-- End Piwik Code -->

    Anyone aware of this or having the same problem?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Correction on that: only the preview shows the wrong setSiteId, the source of the sites reveal that the the correct setSiteId is being used.
    However the still try to access Piwik via the URL containing the IP-number.

    Plugin Author braekling


    I’ve already checked and tried these reports and suggestions. Still no luck. What baffles me though is that Piwik spits out the correct tracking code, so with my correct hostname and not with an IPv4 address, whereas wp-piwik uses the IPv4 address in the tracking code.
    It is just that nothing has changed for weeks, only the upgrade of wp-piwik…

    Meanwhile I’ll try some other things to solve this.

    Plugin Author braekling


    The tracking code is delivered by Piwik. Try to call the API using your browser:


    You also tried to disable the trusted domain feature?

    Please try to set “piwikUrl” to your Piwik URL used in WP-Piwik, too, if the first try without piwikUrl delivers the IP-based tracking code.

    I triple checked the API call and it still differs from the tracking code that can be obtained through the management interface of Piwik.
    I’ve set enable_trusted_host_check=0 and made the API call again and management interface check again. Still the same.

    Anyway, I don’t think this is a problem that is wp-piwik related, but piwik itself. So I’ll drop it overthere and close it overhere.

    Thanks for your suggestions and your good work!

    I have a similar problem. I need to set the piwikUrl to get the correct Code. How can I achieve this in the latest version?

    Plugin Author braekling


    Currently there is no way to set the piwikUrl because Piwik should deliver the correct tracking code if the “trusted domain” is used.

    I’ll keep this in mind for

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Generated tracking code incorrect’ is closed to new replies.