Piwik is an open source alternative to Google Analytics and is open for developers to build their own plugins for their unique web analytics needs. [Demo]
Piwik has a similar basic implementation as Google Analytics. Users simply copy and paste a small JavaScript code on their site to collect data and it can be hosted on a completely independent server.
There are many benefits using open source analytics tools, such as Piwik. Analysts, for example, can adjust Piwik to fit their unique needs – such as tracking referrals from specific sites (such as affiliates), review outgoing links, or flag specific trends (such as visits from Google Search).