I've read a previous thread a few months ago asking for advices on analytics for a startup, you can find it here : http://news.ycombinator.com/item?id=4707903
In it you can find multiple open source solutions such as Piwik (see sheff comment), snowplow (https://github.com/snowplow/snowplow) and Graphite (http://graphite.wikidot.com/start).
Hope this helps.