Search code examples
ruby-on-railsruby-on-rails-3google-analyticsanalytics

Best way to go about creating in-house analytics for my Rails 3 app?


I have a Rails 3 app that I'm looking to create in-house analytics for. The items I need to track are impressions (and unique impressions), clicks that come from those impressions, and conversions that come from those clicks. And these are all user-specific so each user can see how many impressions, clicks, and conversions they've received.

What is the best way to go about this? Should I create a separate rails app and call it with pixels? Or should I include all the analytics code in the same app?

Also, are there any analytics platforms already out there that I can customize to meet my needs?

Thanks!

Tim


Solution

  • Before you start re-inventing the wheel, Google Analytics provide a developer API (via OAuth, among other choices) that may provide you with the ability to do what you need (provide each user with a view of their own data).

    http://code.google.com/apis/analytics/docs/gdata/home.html

    Building your own, while it may seem like an initially basic thing to do, could have serious performance implications further down the line, and Google provide a very detailed view of the the data.

    If you really want to write your own, I would strongly urge you not to hit the database for each request you want to track. Keep the data in Redis, or one of the alternatives and periodically persist it to the database via a background task.