WordPress.org

Ready to get started?Download WordPress

Forums

WP-Piwik
[resolved] Generated tracking code incorrect (8 posts)

  1. phsab
    Member
    Posted 1 year 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']);
    _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://123.123.123.123/"
        _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);
      })();
    </script>
    <!-- End Piwik Code -->

    Anyone aware of this or having the same problem?

    http://wordpress.org/extend/plugins/wp-piwik/

  2. phsab
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year ago #

  4. phsab
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year ago #

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

    YOUR_PIWIK_URL_USED_IN_WP-PIWIK/index.php?module=API&method=SitesManager.getJavascriptTag&idSite=2&piwikUrl=&format=xml&token_auth=YOUR_PIWIK_AUTH_TOKEN_USED_IN_WP-PIWIK

    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. phsab
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year 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 0.9.9.7.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic