Best way to create custom analytics for my Rails 3 application?

I have a Rails 3 application that I am looking for to create my own analytics. The items I need to track are impressions (and unique impressions), clicks from those impressions, and conversions that come from these clicks. And they all depend on the user, so each user can see how many impressions, clicks and conversions they received.

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

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

Thanks!

Tim

+6
source share
3 answers

Before you start reinventing the wheel, Google Analytics provides a developer API (through OAuth, among other options) that can give you the ability to do what you need (to give each user an idea of ​​their own data).

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

Building your own, although it may seem like this is initially the main thing, can have serious performance implications in the future, and Google provides a very detailed overview of the data.

If you really want to write your own, I strongly recommend that you not hit the database for every query that you want to track. Store the data in Redis or one of the alternatives and periodically save it to the database using a background task.

+6
source

If, however, you do not want to put your data in the clutches of our Google Overlord :), then you can really think about turning your own. I had it twice before - and I'm doing it again right now: better this time, of course!

If your traffic is not very high and you work on any decent server platform, then adding a tracking system will not tax your Rails application noticeably (I know that it depends on what a “decent server platform” means, but this stuff in these days are pretty cheap). Writing to the database is usually very fast - you must have shedloads of clicks so you don’t want to do this right away. You can possibly get around most, if not all of your before_filters, and so on to get a lightning response. For example, an application using 2.3.9 uses Metal to do this.

In my new tracking system, I have an STI table that comes with models derived from the Activity model; Here you can record both impressions and clicks. Impressions are recorded as the page is created and clicks are recorded using AJAX.

I will not worry about fancy graphics, etc. - I am pleased with the raw numbers, but they can be added, of course.

At the moment, my system is only in a regular folder / folder, but I most likely moved it to the engine so that I can use it more easily.

Hope this helps!

By the way, I also use Google Analytics for a number of sites, and this is normal - I just like to do it myself.

+4
source

Depending on how you intend to associate Google Analytics data with a specific user, you may need to double-check the effects of privacy. Google does not allow you to associate your data with any identifying information about the monitored users.

If there is a problem, you can try Piwik as it is open source and you can do what you like. This is written in PHP, not Ruby, which can be a problem. As @ d11wtq mentions, tracking systems can have performance issues if they are not built correctly, so you'd better start with something that has already proven to be effective, if possible.

+1
source

Source: https://habr.com/ru/post/889589/


All Articles