Google Analytics provides solid, aggregate statistics for your Rails app. It answers questions like, “How many visitors do I receive a day?” and “Which parts of my app are most popular?”
It cannot track individual users over time, however. Questions like, “How long does the average user remain active over time?” or “How long does it take the average user to go from a free to a paid account” require user analytics.
There is another option, a free, open-source Ruby gem (technically, a Rails engine) called Ahoy. In just a few minutes, you can have robust user analytics for your Rails app.
Let’s walk through an example; say that on our site we want to track visits and actions for each user.
First, install Ahoy and perform the post-installation steps. This takes only a few minutes.
Visit tracking starts immediately after you install Ahoy. You can customize the length of each visit (i.e. after how long does one visit turn into two); it defaults to 4 hours.
Ahoy automatically ties each visit to a user. You not only know how many visits you receive each day, but which users visit the most. Already, we have user analytics.
ahoy.track("Added todo item");
If the user takes an action handled by your Rails code, log it with Ruby:
ahoy.track "Deleted todo list";
Third-party services vs. Ahoy
Mixpanel and KISSMetrics offer advanced reporting out of the box, but have a cost and require you to send your user data to a third party. If you choose to leave either service, extracting your data in a useful way is difficult.
Ahoy is free and your data stays local, but you’ll spend time creating a stats dashboard and reports.
There is no right answer, but while evaluating user analytics tools, be sure to consider Ahoy alongside the paid options.
Hired.com brings Rails job offers to you. Free for candidates. Salaries from $75,000 to $250,000. Sign up now!