I’ve been helping InfoMeters develop their on-boarding and user management flows. We realized things can go a lot faster if we got their development outside of Rails, so they could build the logic they wanted inside apps meant to deliver the same functionality, without needing to code everything by hand. Turns out that the growth / analytics world has tools ready for the job.
- Track each API user’s usage of the app
- Show each user a chart of their own usage over time
Since we want to do this with as little coding as possible, we’ll lean on the following popular 3rd party tools:
- Segment.IO fans data and events out to the relevant tools which each perform their own role. We’re only using one tool in this example, but, trust me, you want to integrate these guys first so other tools can be simply turned on/off when you decide you want to try them.
- Keen.IO acts as the data warehouse, logging event and usage data and performing and visualizing all kinds of queries with their simple SDK.
1. Register for Segment.IO and Keen IO
Put your Keen IO secret key into your Segment.io integrations panel, and turn on the green slider.
2. Pick up your Segment.io secret key
It’s on their Ruby setup guide. You’ll need this in the next step.
3. Setup Segment.io into Rails
- Add Segment.IO to your Gemfile
- Initialize Segment.IO from inside config/initializers/analytics-ruby.rb
Analytics.init(secret: ‘[Your Segment.io Secret Key]’)
4. Track important activity when users perform those actions
In your Rails code, wherever you want to track a special event:
You can also include other user attributes in the :properties hash. InfoMeters is using this approach, tracking each use of the SDK, passing up a client API key that’s known to both their web application and their Android/iOS SKDs, to combine per-client analytics reported from each environment. Keen will let us filter events for those matching properties (like a certain API key) which lets us look at users’ data individually, later.
5. Visualize each user’s usage on their dashboard (or any page you’d like)
Unfortunately, it’s very complex. Luckily, friendly open-source folks at CultivateStudios built a wrapper around Keen’s SDK called Keentivate, which provides a very simple interface to the same code. Let’s use that. =^]
5.5 Now, where you want the chart to show up, add the right HTML:
The following chart should show a line graph of Used Feature X events, performed by the current user over time.
Special thanks to @calvinfo for helping me sort out some of the technical mashingups between Segment.io and Keen.io, @michellewetzler for introducing me to the idea of keen-powered per-user analytics, @Joe_Wegner for the Keentivate library and to the Keen.io and Segment.io teams for great products with amazing service.