WordPress.org

Ready to get started?Download WordPress

Forums

WP-Piwik
[resolved] Implement PHP Tracker API (2 posts)

  1. raubvogel
    Member
    Posted 7 months ago #

    Hi, braekling,

    I like your plugin – it’s nice help for Piwik. But I have a problem: I don’t want to track users by JavaScript or Image. Piwik has an alternative: Piwik Tracking API (Advanced users)

    It’s a PHP class (PiwikTracker.php) that has to be called if a page is loaded. Do you think you can add this feature to your great plugin? If you want I can do the implementation too and create a SVN patch.

    I will give a basic implementation:

    // write log to piwik
    $t = new PiwikTracker(SITE_ID));
    
    // optional tracking
    $t->setUserAgent(self::validString($_SERVER['HTTP_USER_AGENT'], false));
    $t->setUrlReferrer(self::validString($_SERVER['HTTP_REFERER'], false));
    //$t->setBrowserLanguage('de');
    //$t->setLocalTime( '12:34:06' );
    //$t->setResolution( 1024, 768 );
    //$t->setBrowserHasCookies(true);
    $t->setCustomVariable(2, 'httpStatus', $httpStatus);
    //$t->setPlugins($flash = true, $java = true, $director = false);
    $t->setTokenAuth(PIWIK_AUTHTOKEN));
    $t->setIp(self::validString($_SERVER['REMOTE_ADDR'], false));
    $t->setForceVisitDateTime('now');
    
    // TODO: $_SERVER['SERVER_PROTOCOL'] return http only never https
    // mandatory
    $t->setUrl(self::validString('http://' . MY_DOMAIN . $_SERVER['REQUEST_URI'], false));
    $t->doTrackPageView(CURRENT_PAGE_TITLE);

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

  2. braekling
    Member
    Plugin Author

    Posted 7 months ago #

    PHP API is supported since 0.9.4, currently still implemented as "BETA". See tracking settings.

Reply

You must log in to post.

About this Plugin

About this Topic