Daily using/supporting

Get Firefox browser!
Get Thunderbird!
Get Opera browser!
Get The Gimp!
Get Inkscape!
Get LibreOffice!
Get Videolan!
Get Linux!
Get Mandriva!
Get Joomla!
Hacker Emblem

Archives

Which topics would you like us to cover more?

Latest comments

Latest tweets

about 1 day ago Using REDIPS.drag to add drag and drop to your .Net webapplication #li #dib0 http://t.co/n8zY3s7d
about 7 days ago http://t.co/cknQcDbo #Kindle
about 15 days ago Freedom isn't the ability to choose what to do or say, but the ability to choose what not to do or say #freedom
about 29 days ago http://t.co/61KTQknI #Kindle
12 Apr 2012 Force the use of a networking adapter using C# #li #dib0 http://t.co/ZTJOPzOz
9 Apr 2012 Mandriva 2010.2 and USB devices in Virtualbox http://t.co/fwq9gbHB
9 Apr 2012 Execute a http request to you own site with PHP http://t.co/DIvWPrpd
Home Architecture, security and coding Joomla RSS Feed stats in Piwik
Joomla RSS Feed stats in Piwik
Written by Division by Zero   
Thursday, 26 May 2011 15:21

As you may know or have noticed I don't use Google Analytics. Instead I use an open source variant called Piwik.

I really love Piwik, but always had one wish: I want to see the visitors that read this blog through feeds. After some time of trying and searching I decided to write my own Joomla plugin that uses the Piwik Tracking API. Here are some code snippets to show you how it's done. If you want the plugin, download it here:

The Joomla plugin isn't very complicated. Without the standard plugin code, the actual Piwik Tracking code looks like this. I used the onAfterDispatch event to track this request with Piwik.

$mainframe = JFactory::getApplication();
// Only modify site pages that are not admin, install, etc.
if ( $mainframe->isSite() )
{
    // Only add stats for feed requests
    if ( $_REQUEST['format'] == 'feed' )
    {
        // Require the Piwik integration file
        require_once 'PiwikTracker.php';
        // Create tracker
        $piwikTracker = new PiwikTracker( $idSite = $this->params->get('siteid'), $apiUrl = $this->params->get('piwikuri'));
        $piwikTracker->setUrl( $url = $_SERVER['REQUEST_URI'] );
        // The auth token is required for overriding the server data with the original user data (such as IP-adress)
        $piwikTracker->setTokenAuth( $this->params->get('piwikauthtoken') );
        // Sends Tracker request via http
        $piwikTracker->doTrackPageView($this->params->get('pagetitle'));
    }
}
 

Add comment


Security code
Refresh

If the human brain was simple enough for us to understand we'd be so simple we couldn't understand. - Unknown


© 2009 - 2012, Division by Zero

Template based on the empire template by joomlashack 

Valid XHTML 1.0 Strict  Valid CSS!  Creative Commons License
This work by Division by Zero is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Netherlands License.