WordPress.org

Ready to get started?Download WordPress

Forums

WP-Piwik
[resolved] idSite on a WP site: doesn't track (26 posts)

  1. edou
    Member
    Posted 1 year ago #

    Hi,

    I've got the following problem:
    I'm testing now a website, let's say http://www.site.com which is still under construction.
    Waiting till it is ready, I hard coded the javascript (with "idSite=1" in the index construction page.

    On another folder of the root is the real (in progress) website using WordPress. Piwik is normally installed in it's own folder, as well as the plugin.

    In the piwik CMS (outside wordpress cms), I created 3 websites: one for the construction page (idsite=1), one with the in progress folder (www.site.com/progress, with idsite=2) on which WordPress is installed. The last one is a subdomain website with idSite=3

    For some reason that I can't explain, the only tracking code that works is number 1. Both idSite 2 and 3 never detect a connection

    Is it normal? Is there anything to do about it? Could that have anything to do with the fact that I yet don't allow robots to refer 2 and 3?

    Thanx for your answers.

    E

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

  2. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Does WP-Piwik add the correct tracking code to site 2?
    Is site 3 a WordPress site running WP-Piwik, too?
    Does WP-Piwik itself work fine and only the tracking code does not work?

    Please consider this support forum is just about the plugin WP-Piwik, not about Piwik itself. If the tracking code added to site 2 is correct, the not-working site 3 doesn't use WordPress and WP-Piwik itself is working fine, you should ask the Piwik community, see http://www.piwik.org

  3. edou
    Member
    Posted 1 year ago #

    Hi, thx for your answer.
    I don't really know how to determine whether wp-piwik or piwik a problem is.
    To give it a try last night, I hard coded in site 3 the same tracking code than site 1 (specifying site3 naturally). And then it records visits.
    What I can see, is that if I tell wp-piwik to use wp_footer(), there is no cookie set to the browser. So it makes sense that no record is registered. Why that part doesn't work, I don't know.
    Would that mean that piwik doesn't work properly?

    You can my post hier: http://wordpress.org/support/topic/tracking-works-only-with-hard-coding?replies=1

  4. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Please have a look at your site's source code, copy the tracking code added by WP-Piwik and post it here. Thx.

  5. edou
    Member
    Posted 1 year ago #

    For site 1 (maindomain):

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <!-- Piwik -->
    <script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.kvdb.nu/statistiek/piwik/" : "http://www.kvdb.nu/statistiek/piwik/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    </script><script type="text/javascript">
    try {
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
    piwikTracker.trackPageView();
    piwikTracker.enableLinkTracking();
    } catch( err ) {}
    </script><noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Tracking Code -->
    
    For site 3 (subdomain):
    <!-- Piwik -->
    <script type="text/javascript">
    var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.kvdb.nu/statistiek/piwik/" : "http://www.kvdb.nu/statistiek/piwik/");
    document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
    </script><script type="text/javascript">
    try {
    var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 3);
    piwikTracker.trackPageView();
    piwikTracker.enableLinkTracking();
    } catch( err ) {}
    </script><noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=3" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Tracking Code -->
    
    I just made a try on site 2 (subfolder of maindomain) pasting the code generated by piwik and that wp-piwik could see, but that doesn't work, apparently also not when hard coded:
    
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
      _paq.push(["setCookieDomain", "*.kvdb.nu"]);
      _paq.push(["setDomains", ["*.kvdb.nu"]]);
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);
    
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.kvdb.nu/";
        _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>
    <noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
  6. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Did you copy these tracking codes from the WP-Piwik settings page, or did you copy these tracking codes from your sites source codes?

  7. edou
    Member
    Posted 1 year ago #

    for 1 and 3, I got the code from piwik site directly, and hard coded it.
    for site 2, i got it from piwik interface.
    The one generated in wp-piwik would be the following:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
  8. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    See http://wordpress.org/support/topic/tracking-code-has-bare-ipv6-address?replies=5

    If the linked thread won't help: Please copy the tracking code from your sites source code - not the code shown by Piwik or WP-Piwik.

  9. edou
    Member
    Posted 1 year ago #

    I'm going to have a look to the thread. I'll let you know.

    The last code generated by wp-piwik doesn't work when hard coded.
    when i activate the use of wp_footer(), the source of the page shows the following one:

    [ Moderator Note: Really please post code or markup snippets between backticks or use the code button. ]

    <!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
  10. edou
    Member
    Posted 1 year ago #

    I've had a look to the post.
    So far, I noticed that my trusted hostanem was http://www.kvdb.nu. Should it be something else regarding the fact that the piwik folder is stored in a subfolder?
    I gave it a try by changing it to http://www.kvdb.nu/thepath, and within no time I had a bunch of error messages.

  11. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Did you try to disable the "trusted hostname" feature? At least to know if your issue is caused by this?

  12. edou
    Member
    Posted 1 year ago #

    i just did disable it, and it immediately started to track when I called the site.
    Is there anything else to do to solve that problem?

  13. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    WP-Piwik gets the tracking code using the Piwik API. Obviously Piwik delivers a not working tracking code which contains your severs IPv6 instead of your Piwik's trusted hostname. Usually this issue occurs if your Piwik URL configured in WP-Piwik differs from the trusted hostname configured in Piwik.

    If your Piwik URL configured in WP Piwik equals the trusted hostname, try to call the API manually: http://PIWIK_URL/index.php?module=API&method=SitesManager.getJavascriptTag&idSite=SITE_ID&piwikUrl=&format=xml&token_auth=AUTH_TOKEN

    If Piwik still delivers a tracking code using the IPv6, please ask the Piwik community: http://forum.piwik.org Otherwise post the API response for comparison.

  14. edou
    Member
    Posted 1 year ago #

    Just to check, I replaced PIWIK_URL by my site url followed by the path to the piwik folder, SITE_ID with 2 and AUTH_TOKEN with the provided by piwik for site 2. Nothing more.

    I got this result, with no ipv6:

    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <result><!-- Piwik -->
    <script type="text/javascript">
    var _paq = _paq || [];
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.kvdb.nu/statistiek/piwik//";
    _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>
    <noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
    </result>

  15. edou
    Member
    Posted 1 year ago #

    I must specify that the trusted hostname is still disabled

  16. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    You are posting different tracking codes from different sources, from different Piwik versions and using different settings. So it is not possible to compare your codes.

    First: Did you re-enable the trusted domain feature before testing manually? Otherwise your lastly pasted tracking code is not meaningful.

    To get comparable codes:

    1. Choose ONE of your sites. This site should run WordPress and WP-Piwik.
    2. Keep sure to (re-)enable Piwik's trusted domain feature.
    3. Check & post the tracking code shown at the WP-Piwik settings page.
    4. Check & post the tracking code added to your site's source code (Note: if you meanwhile updated Piwik & WP-Piwik, the tracking code is added to your sites header).
    5. Check & post the tracking code delivered by a manually API call using the same settings as before.

    Please follow the moderators note to post your tracking codes between backticks or by using the code button.

  17. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    If the trusted hostname is still disabled your posted tracking code is not useful ;)

  18. edou
    Member
    Posted 1 year ago #

    Ok, I'm going to do that on the subfolder site where I'm busy building content (site 2).
    I'll forget the subdomain (site 3) since I have to start it from scratch for different reasons. And site 1 is not a WP site, just the index of the root folder on the server.

  19. edou
    Member
    Posted 1 year ago #

    I'm using Piwik 1.11 and WP-Piwik 0.9.8.1

    1- ok, site 2
    2- done
    3-

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->

    4-

    <!-- *** WP-Piwik - see http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress/ -->
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
    <!-- *** /WP-Piwik *********************************************************** -->

    5-`<!-- Piwik -->
    <script type="text/javascript">
    var _paq = _paq || [];
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
    (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.kvdb.nu/statistiek/piwik//";
    _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>
    <noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
    `

  20. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, thank you. There must be a difference between your manual API call parameters and the parameters used by WP-Piwik.

    1. Please update to WP-Piwik 0.9.9.0 - it comes with compatibility fixes regarding Piwik 1.11. Re-check your tracking code after updating (it should contain your Piwik URL, not the IPv6).

    2. "Trusted domain" was still enabled while you called the API manually (step 5)?

    3. Post the URL you used to call the API manually (remove auth token!). Go to WP-Piwik's support tab and run the testscript. Post its result here, too.

  21. edou
    Member
    Posted 1 year ago #

    I updated both piwik to 1.11.1 and wp-piwik to 0.9.9.0.
    NB: I noticed since version 1.9 that when I want use the options for the tracking code that nor piwik nor wp-piwik remembers thoses changes.
    With the last test was "trusted domain" enabled
    It seems the IPv6 problem is still there.

    1- Tracking code from Piwik:

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(["trackPageView"]);
      _paq.push(["enableLinkTracking"]);
    
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.kvdb.nu/statistiek/piwik/";
        _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 -->

    2- tracking code from wp-piwik:

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->

    3- URL for API test and result:
    http://www.kvdb.nu/statistiek/piwik/index.php?module=API&method=SitesManager.getJavascriptTag&idSite=2&piwikUrl=&format=xml&token_auth=XXXXXXXXXXX

    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.kvdb.nu/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://www.kvdb.nu/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
  22. edou
    Member
    Posted 1 year ago #

    4- the code from the page source (indeed in the header):

    <!-- *** WP-Piwik - see http://wordpress.org/extend/plugins/wp-piwik/ ******** -->
    <!-- Piwik -->
    <script type="text/javascript">
      var _paq = _paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik//";
        _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>
    <noscript><p><img src="http://2a01:7c8:eb:0:95:170:70:70/statistiek/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
    <!-- End Piwik Code -->
    <!-- *** /WP-Piwik *********************************************************** -->
  23. edou
    Member
    Posted 1 year ago #

    I just made a test disabling the "trusted domain" and noticed the following:
    where the IPv6 url shows when "trusted domain" enabled (2 and 4), I have domain name "kvdb.nu" when disabled.
    where the IPv4 url (www.kvdb.nu) shows when "trusted domain" enabled (1 and 3), I have domain name "www.kvdb.nu" when disabled.

    I went to the wp-piwik setting and saw that I didn't use the www. before domain name in piwik url. I made the correction, tested with "trusted domain" disabled, and then enabled it.

    It now works properly.
    So I give you a BIG THANK for your help on that problem.

    I'm wondering what's going to happen when I want to use a subdomain later on regarding the IPv6 url problem. Is there anything special to do about it to prevent confusion?

    I still have the issue that piwik doesn't update when I use the tracking code options. But I sense you'll say I should ask in the piwik forum?

  24. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    The "IPv6" problem only occurs if the trusted domain does not equal the Piwik URL configured in WP-Piwik. If you want to access the same Piwik instance using different domains (also subdomains), you have to disable the trusted domain feature.

    Regarding the tracking code options offered by Piwik - yes, please ask the Piwik community ;) I'm quite sure these options aren't intended to be saved, but rather to mix your own tracking code to copy & paste.

  25. edou
    Member
    Posted 1 year ago #

    About the subdomain: is it then an option to install a second piwik to match the url?

    about the options for the tracking code: copy paste doesn't work if you use the wp_footer() as tracking method in wp-piwik, isn't it?

  26. braekling
    Member
    Plugin Author

    Posted 1 year ago #

    I don't think it makes sense to install a second Piwik just to keep trusted domain enabled.

    Btw: You don't need to disbaled trusted domains to track different subdomains. You only need to disabled trusted domains if you like to reach one Piwik installation using multiple domains.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic