User Engagement

You can use Keen to find out how many times per week your users are interacting with your app.

With this approach, you’ll be able to answer how many hours per week someone has used your app as well as how many days per week a user has used your app.

To accomplish this, there are two components. One is the data modeling and recording of data; the other is the querying and post-processing of the query results.

When collecting data, we recommend you have an event called “user_engagement” that is recorded any time a user performs an action that you consider “engagement” – such as logging in, reading an email, etc.

A user_engagement event will have some specific properties that look like this:

{
  user: {
    id: 123456,
  },
  day: "2014-03-14T00:00:00Z", //note the time is zeroed out and the timezone is zulu
  hour: "2014-03-14T15:00:00Z", //note the minutes/seconds are zeroed out and the timezone is zulu
  your_other_properties: "other_values"
}

Basically, we’re recording the current day, and current hour that the user was engaged.

Now, to find out how many days each user has used the app this week, we’ll run this query on the user_engagement collection:

var dailyEngagement = new Keen.Query('count_unique', {
    event_collection: 'user_engagement',
    target_property: 'day',
    timeframe: 'last_7_days',
    group_by: 'user.id'
});

This query will return a result that looks like this:

{
 result: [
   {
     user.id: 123456,
     result: 3
   },
   {
     user.id: 67890,
     result: 6
   },
   ...
 ]
}

In this example, user 123456 used the app on 3 unique days within the last_7_days. User 67890 used the app 6 (!!!) unique days within the last_7_days.

From there we can determine what percentage of users use the app various numbers of days per week.

Now if we want to find how many hours per day someone uses the app, we can follow a very similar formula:

var hourlyEngagement = new Keen.Query('count_unique', {
    event_collection: 'user_engagement',
    target_property: 'hour',
    timeframe: 'last_7_days',
    interval: 'daily',
    group_by: 'user.id'
});

The query will return something that looks like this:

{
 result: [
   {
     timeframe: {
       start: <an ISO-8601 string>,
       end: <an ISO-8601 string>
     },
     values: [
       {
         user.id: 123456,
         result: 1
       },
       {
         user.id: 67890,
         result: 3
        },
        ...
     ]
   },
   {
     timeframe: {...}
     values: [...]
   },
   ...
 ]
}

This query returns how many unique hours each user has been interacting with your app each day! From here we’ll be able to tell how many hours each day someone interacted with your app.

Now you can process these results to determine how addicted your users are to your app!