WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Tracking doesn't work

[Resolved] Tracking doesn't work

  • Both on my piwik installation (I maintain two sites) and at the local Piwik data within WP there is no data recorded for my WP site after upgrading to WP 3.8, while the JetPack shows at least more visitors, I will try to manually appending the javascript instead of using WP-Piwik.

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

Viewing 15 replies - 16 through 30 (of 30 total)
  • Why Piwik?

    Before i install the wp-piwik update, the tracking works fine. After that the tracking is stopped. I’am sure this is a wp-piwik bug!

    On my other sites (typo3) piwik (is the same one) works fine!

    OK, I just checked and it’s working now, here’s my config:
    Piwik is fine.

    I’ve added the tracking code from my main Piwik install for my WordPress site to my child theme’s footer.php, just above </body>.

    WP-Piwik shows a wrong SiteId and it doesn’t update itself.

    Time to uninstall and do as I did…

    WP-Piwik adds a reference at the webpages to piwik.js at the root of the server, which is not found (404).

    chrisbfotografie
    Member

    @chrisbfotografie

    Thx druppel!

    Did the same for now. Deactivated WP-Piwik and added the tracking code manually to my Child-Theme’s footer.php, because the timeout of the script also made my blog load really slow.

    Hope the problem gets solved soon.

    Plugin Author braekling
    Participant

    @braekling

    -> If the site id is wrong, you should try to reset WP-Piwik. Go to “settings -> support” to check the estimated site IDs (site configuration details) and to reset WP-Piwik’s settings.

    -> If you are using Piwik’s standard tracking code, WP-Piwik will fetch the tracking code from Piwik itself. This tracking code also should load Piwik’s piwik.js (see the Piwik root directory to find piwik.js).

    mgc8’s problem sounds really strange (the debug script uses the same functions as WP-Piwik itself… so a working debug script should be equal to a working WP-Piwik setup) and I’m really sorry I don’t have an idea how to solve it.

    But this differs from the other problem which is caused by the “not found” piwik.js – to get behind this I need some more information, e.g. what is your (WP-Piwik!) tracking code looking like? Does WP-Piwik work if you just disabled tracking and add the tracking code manually? Did you try to use the “js/index.php” tracking?

    By the way: If you don’t change WP-Piwik’s settings, the tracking code will not change if you update Piwik itself. In that case an issue caused by the tracking code delivered by Piwik won’t occur until WP-Piwik is updated (and the tracking code is updated automatically). So without detailed information I can’t tell you if the issue is caused by WP-Piwik or Piwik.

    Thank you very much for building the plug-in, I’ve used it a lot, but when things start to malfunction, regardless of who could be blamed, it gives me peace of mind to know everything is now built into my child theme. 🙂

    Only when one has a Piwik-installation separate from a WordPress-installation one could follow the next steps:

    On ones main installation:
    – log in to Piwik.
    – make a new website inside Piwik.
    – copy the tracking code of the new website.

    On ones WordPress-site:
    – make a Child Theme
    – copy footer.php from the template theme folder to the child theme folder
    – paste the tracking code from the main Piwik-installation just above </body> in the child theme’s footer.php

    “mgc8’s problem sounds really strange (the debug script uses the same functions as WP-Piwik itself… so a working debug script should be equal to a working WP-Piwik setup) and I’m really sorry I don’t have an idea how to solve it.”

    Well, that’s quite unfortunate… Maybe we can help debug this so you can get a better idea? For the record, I just updated to the latest version of WP-Piwik (0.9.9.8) and the behaviour is the same.

    Here is what the second test reports, I would guess the format is somehow incompatible with what WP-Piwik expects?

    “*** Test 2/2: SitesManager.getSitesIdFromSiteUrl ***
    (…)
    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <result>
    <row>
    <idsite>4</idsite>
    </row>
    </result>
    Time: 0.05s

    The reason I’m saying that is because on the “Get site configuration details” page there is no proper ID detected. So it seems WP-Piwik can’t get the ID correctly, therefore it doesn’t get the tracking code either… does that make any sense?

    Ok, so I tracked this down to the considerable API changes in Piwik 2.0. Frankly I believe this works only for people who use the “REST” API, it should break for everyone using the “PHP” one, given that on my system the “callPHP” function returned NULL constantly before I patched it.

    Anyway, the problem is basically that Piwik switched to using namespaces extensively and all code has been re-factored to take this into account. Given that WP-Piwik includes Piwik source code directly and instantiates the “Piwik_API_Request” class, it fails silently due to the class being renamed to “Piwik\API\Request”.

    So here it goes… In “wp-piwik.php”, replace the “function callPHP()” with the follwing:

    function callPHP($strParams) {
                    if (PIWIK_INCLUDE_PATH === FALSE)
                            return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$settings->getGlobalOption('piwik_path')).'": '.__('realpath() returns false','wp-piwik').'.'));
                    if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
                            require_once PIWIK_INCLUDE_PATH . "/index.php";
                    if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
                            require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
                    if (class_exists('Piwik_FrontController'))
                            Piwik_FrontController::getInstance()->init();
                    else if (class_exists('Piwik\FrontController'))
                            Piwik\FrontController::getInstance()->init();
                    // Add Piwik URL to params
                    $strParams .= '&piwikUrl='.urlencode(self::$settings->getGlobalOption('piwik_url'));
                    // This inits the API Request with the specified parameters
                    if (class_exists('Piwik_API_Request'))
                            $objRequest = new Piwik_API_Request($strParams);
                    else if (class_exists('Piwik\API\Request'))
                            $objRequest = new Piwik\API\Request($strParams);
                    else return NULL;
                    // Calls the API and fetch XML data back
                    return $objRequest->process();
            }

    … this should make Piwik detect the site correctly. The tracking code is still not picked up right, but I guess similar changes have to be made to the code there.

    Hope this helps in tracking it down.

    Regards,
    Mihnea

    Plugin Author braekling
    Participant

    @braekling

    Thank you very much!

    I didn’t know you are using the PHP API. Now I have a hint to figure this out… and of course I’ll do so 😉

    dEM0nsTAr
    Member

    @dem0nstar

    Could you please fix this officially?
    Since I updated Piwik from v1 to v2 WP-Piwik doesn’t track my visitors anymore…
    Thanks in advance!

    Plugin Author braekling
    Participant

    @braekling

    This will be fixed officially by and by – as I wrote above.

    Meanwhile please switch to the REST API, which is not in beta status (compared to the PHP API).

    dEM0nsTAr
    Member

    @dem0nstar

    I always use and used the REST API but it doesn’t work anymore since I updated Piwik to v2:

    *** Test 1/2: SitesManager.getSitesWithAtLeastViewAccess ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: http://www.domain.tld/piwik/?module=API&method=SitesManager.getSitesWithAtLeastViewAccess&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Server: nginx
    Date: Sun, 02 Feb 2014 18:49:46 GMT
    Content-Type: text/xml; charset=utf-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    Vary: Accept-Encoding
    X-Powered-By: PHP/5.5.8-1~dotdeb.1
    Set-Cookie: PIWIK_SESSID=ogq3fu7lrsi1f4fub9qmh8ra50; path=/; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <result>
    <row>
    <idsite>1</idsite>
    <name>Blog</name>
    <main_url>http://www.domain.tld</main_url&gt;
    <ts_created>2009-12-31 00:00:00</ts_created>
    <timezone>Europe/Berlin</timezone>
    <currency>EUR</currency>
    <excluded_ips />
    <excluded_parameters />
    <excluded_user_agents />
    <sitesearch>1</sitesearch>
    <sitesearch_keyword_parameters />
    <sitesearch_category_parameters />
    <group />
    <type>website</type>
    <keep_url_fragment>0</keep_url_fragment>
    <ecommerce>0</ecommerce>
    </row>
    </result>
    Time: 0.12s

    *** Test 2/2: SitesManager.getSitesIdFromSiteUrl ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: http://www.domain.tld/piwik/?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=http%3A%2F%2Fwww.domain.tld&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Server: nginx
    Date: Sun, 02 Feb 2014 18:49:46 GMT
    Content-Type: text/xml; charset=utf-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    Vary: Accept-Encoding
    X-Powered-By: PHP/5.5.8-1~dotdeb.1
    Set-Cookie: PIWIK_SESSID=6lt56dhbap3scfrnjjs79pvgi6; path=/; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache

    <?xml version=”1.0″ encoding=”utf-8″ ?>
    <result>
    <row>
    <idsite>1</idsite>
    </row>
    </result>
    Time: 0.11s

    001101
    Member

    @001101-1

    Same Problem here, just don’t works, would be nice if a REAL FIX is possible…

    Plugin Author braekling
    Participant

    @braekling

    deM0Nstar:

    Please don’t mix different topics. The problem describe by mgc8 is only regarding the PHP API. So also the fix will only work for this issue.

    Which tracking mode are you using? If it is proxy mode, please try another one. In this case I may have an idea about a solution, see http://wordpress.org/support/topic/doesnt-work-when-proxy-script-is-configured

    001101: Please switch to the REST API until the fix is not available.

    Plugin Author braekling
    Participant

    @braekling

    The PHP API issue is fixed in 0.9.9.9.

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘[Resolved] Tracking doesn't work’ is closed to new replies.