This post covers how to begin tracking business metrics in three simple steps, without the need for any complex event tracking in your code, instrumentation, or metrics database.
Step 1: Log your metrics
The first thing you need to do is to log events you want to track. Logging your data rather than writing events you want to track directly to a database has a number of advantages as highlighted in separate posts by a lot of different folks of late – e.g. see Wanelo’s approach to business metrics tracking using logs, Heroku’s logs as performance metrics or Jeff Dik’s post on logs as versioning.
Some good tips on how to structure your log events are outlined in Ryan Daigle’s 5 Steps to Better Application Logging. In short it’s good practice to:
- Choose a set of events you want to track. In other words put some thinking into what you want to track and don’t just dump everything.
- Configure your log output so that your logs are well structured (key/value pairs are recommended for fields so that they are both human and machine readable).
- Add some context: E.g. session id’s can help with relating events to a particular user session or transaction.
Step 2: Send your logs into the cloud (60 seconds to logging nirvana)
Sending your logs to a SaaS log analysis engine is dead easy! Using the Logentries new logging quickstart guide, for example, I can set up a new account and hook up some sweet logging in ~ 60 seconds. And I’m actually not the quickest typist in the room…
Don’t believe me? I challenge you to try it yourself… if you set up your logging in less than 60 seconds … we’ll send you a much coveted Logentries T-Shirt (pictures will be posted soon – stay tuned) … we’ll use the honor system to verify your time 🙂 Go on give it a try!!!
Step 3: Tag your events and build some flashy reports
Logentries’ new field level search capabilities allow you to use logical operators and field level extraction to perform some powerful analysis. We support AND, OR, NOT operators and also allow you to extract numerical and string field values for comparisons (=,>=,<=,!=). However, you can also apply these same search capabilities when you want to tag (and alert or report) on particular events. This allows you to not only tag keywords or regular expressions but to also tag events when particular thresholds are breached or when something did not happen that you had expected.
Next I give some examples of different types of business metrics that you might want to track, as well as some simple tips on how you can use Logentries to quickly build tags and reports.
Here’s an example log event which records when a user switches to a paid account:
INFO 2013-10-08 00:19:56,642 helpers event=’switch_to_paid’, account_name=’logentries-test’, account_id=’12345′, emails='[firstname.lastname@example.org]’, created=’2013-10-05′
To begin tracking your business metrics you will need to create tags for the activity you would like to track (e.g. signup, login, payments etc.). To create a tag select the log in Logentries containing the data of interest, next select the ‘tagging’ tab and create a new tag. Then give the tag a name and specify the pattern in your log event that relates to the business event you want to track. For example in the log event above I want to identify any events where a user switches from a free plan to a paid plan (‘event=’switch_to_paid’). Here’s how I set it up…
You’ll notice I gave the tag a name and specified a pattern that should be matched. In this case the pattern was a simple keyword expression (event=’switch_to_paid’), however you can also make use of regex, logical operators or our field level extraction when specifying what should be matched. Here’s some more tags that I created that relate to key events we wanted to track:
Finally, you can build a report that graphs these KPIs. To build a report simply select the ‘Graphs’ tab, hit the ‘create widget’ button and select the tags you want to visualize.
And here is the resulting report I created showing how users converted on a given day:
Note, Logentries allows you to modify the reports dynamically by selecting whatever time frame and granularity you prefer to view – e.g. last 20 mins, last 24hrs or a particular day of the week for example.
Viola!! No need for instrumentation, complex event tracking or managing of yet another database – just log ’em, tag ’em and report ’em! If you don’t already have a Logentries account get one here for free and get your metrics dashboards up and running in a matter of minutes.