Instant cohorts and retention graphs for your Rails app

Knowing retention and churn is crucial to understanding whether you are doing the right things to get your product off the ground and keeping it successful. By analyzing retention and churn metrics by monthly cohorts, you can easily pinpoint which of your actions were successful or not.

At Firmhouse, we are not doing a good enough job at reporting on these metrics for our side projects yet. The lack of metrics makes it hard to discuss or prove the success of a side project we're trying to bootstrap. I wanted to make a contribution to that discussion and that's why I started developing a little gem called retention_magic.

The promise of this gem is to be a quick, drop-in placement for your Ruby on Rails app that instantly generates insightful retention graphs for your app on a secure dashboard. And all that with only minor configuration.

Here's what that looks like:

The next screenshot shows what the page looks like for one of our startups.

Retention Magic sample page

In the first graph, you can see which user cohorts are most active in our product. The green area represents users that have signed up but have not activated since. The yellow area represents the users that did something once. The red area shows people who did something more than five times. These are the users that activated most. The blue area represents the people who converted into paying users.

In the second graph, the colored areas are not types of activation, but they all correspond to a monthly cohort. The blue area at the bottom of the graph represents all users that signed up in April 2015. By following that area to the right you can see how many of those users that signed up in April 2015, are still active in the subsequent month. Each month generates a new cohort and a new colored area in the graph.

This page is instantly generated based on your current database records and models and accessible on There is no need to set up any extra tracking code in your controllers and views. Just set up the initializer that configures which of your models retention_magic should analyze.

Minor configuration needed

This is how the configuration file looks like in config/initializers/retention_magic.rb:

RetentionMagic.user_class = "User"  
RetentionMagic.activation_counter_columns = [  
RetentionMagic.retention_models = %w( Post TextPost Achievement Comment Vote )  

The first line user_class specifies the primary user model. This is how we distinct individual people signing up and using your app.

The second configuration value activation_counter_columns lists the columns on the user_class User model that count towards an activation action. In this specific case, creating posts, comments, votes, text posts or achievements all count as an individual activation. This configuration value generates the first graph on the page. That graph shows you which people signed up without doing anything, the people that only did one thing, and people that did more than five things.

The third option retention_models sets the class names that are analyzed for retention. The graph looks through the history of each User and counts when they created one of the records for the specified models at a later stage. This way you can answer a question like "How many things did a User do three months after signing up."

Improving discussions and informing everyone involved

I think having a simple screen like this that you can set up within a few minutes gives great insights for yourself, for your team and towards external advisors or maybe even investors. These two graphs provide you a top-level overview of how your app is doing, and which cohorts are performing best. When the colored areas are getting larger, you're doing the right thing. If you see a drop for a few cohorts in a row, you could go back to the successful cohort before that, and analyze what marketing or product strategy was responsible for that successful cohort.