[resolved] Generated tracking code incorrect (8 posts)

  1. Sjoerd Blom (Vertizio)
    Posted 3 years ago #

    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?


  2. Sjoerd Blom (Vertizio)
    Posted 3 years ago #

    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.

  3. braekling
    Plugin Author

    Posted 3 years ago #

  4. Sjoerd Blom (Vertizio)
    Posted 3 years ago #

    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.

  5. braekling
    Plugin Author

    Posted 3 years ago #

    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.

  6. Sjoerd Blom (Vertizio)
    Posted 3 years ago #

    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!

  7. campino2k
    Posted 3 years ago #

    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?

  8. braekling
    Plugin Author

    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Piwik
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic