How to incorporate analytics in your app
In a nutshell, most mobile analytics use simple code that needs to be inserted into your app. The code is inserted at portions that need to be monitored, and the data collected is stored on the smart-phone, and periodically sent to the analytics software provider. There is no impact to the app’s performance due to incorporation of analytics. Further, the data streamed to the server is immediately averaged, so no one incident can be tracked in isolation. This is important for the privacy of the users, as discussed in the last section of the article.
The following are the steps involved in incorporating analytics using Flurry. The procedure offered by other solutions is similar.
Step 1. Sign-up with Flurry, and create an application and mention its category (games, lifestyle, social, tools etc), similar to Android Market [4] categories, to be monitored. Flurry (like others) assigns a unique application key (or API key) for each application. This key will be used from the Android app to make a call to the Flurry service. In Figure 1, the sample Android application laila is assigned a unique application key. You can, at a point, have up to 600 versions of the app that you can simultaneously monitor. All the versions have the same API key.
Figure 1. App name and its unique application key
Step 2. Download the Flurry SDK for Android, which consists of a JAR file. All that you need to do is to add the JAR file to the application’s CLASSPATH. Here, we added FlurryAgent.jar using Eclipse’s Java Build Path and choosing the Add External JAR option (see Figure 2). Import the Flurry library, com.flurry.android.*, in your app.
Figure 2. Added FlurryAgent.jar
Step 3. Configure the AndroidManifest.xml file of the app for granting permission to collect analytics. The most important permission is Internet access, to transmit the collected analytics data to the Flurry servers. Additionally, if your analytics needs permission to track the location, you will have to take explicit approval from users in the Terms of Service (ToS) agreement. In the example below, we used android.permission.ACCESS_COARSE_LOCATION that allows an application to access coarse location metrics by accessing cell and Wi-Fi based location data.
<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”></uses-permission>
Step 4. (Optional) Provide the Android Market ID to benchmark the performance of your app in comparison with other apps in the same category in the Android market. This is the package name of the main class of the application, which you use in the Android Market. For example, the Market ID of the popular angry birds is com.rovio.angrybirds_lite.
Note: The Android Market (currently in beta form) allows users to publish their application in the market for others to download. Any developer who agrees to the terms and conditions for pricing and payments, license grants, returns, can join the Market. The steps involve registration to Android Market with a Google account and paying up a small fee. This will enable him to have an account with an identity for his app. There are also other 3rd party distribution channels—AndAppStore [6], Android Freeware [7]—which offer different payment models a developer can leverage.
Step 5. Tracking the session’s length and events is very important. There are at least two methods to use for getting each session’s length:
- FlurryAgent.onStartSession (Context, String) used in the onStart method of each Activity. Here, a Context object is either an activity or an event, followed by the String that is the application’s API key defined in Step 1.
public void onStart()
{
super.onStart();
FlurryAgent.onStartSession(this, “LAJ5VGW1VM2N4LU7XW3P”);
// your code
}
Flurry recommends the usage of onStart for each Activity in the app, and passing the activity itself as the context object.
- FlurryAgent.onEndSession (Context) used in the onStop method of each Activity.
public void onStop()
{
super.onStop();
FlurryAgent.onEndSession(this);
// your code
}
onEnd is added when a session is complete. One session can have multiple activities. It is recommended to add, for each Activity, a call to onStartSession and end with an onEndSession, passing in the same Context object that was used to call onStartSession. The session continues under the following two cases:
- So long as there is any Context that has called onStartSession but not onEndSession, the session will be continued.
- If a new Context calls onStartSession within 10 seconds of the last Context calling onEndSession, then the session will be continued instead of creating a new session. This way, a single session can span many Activities. The default window of 10 seconds can be altered using the FlurryAgent.setContinueSessionMillis(long milliseconds) before the first call to FlurryAgent.onStartSession.
In addition, you may need to track a number of events, where each event is anything that happens when the application is running and is of interest to you. A list of methods to track events is presented in the developer’s page (http://dev.flurry.com). An example is shown below:
case MORSE_CODE:
FlurryAgent.onEvent(“Morse Code”);
//your code
launchMorse();
return true;
case ROSICRUCIAN_2:
FlurryAgent.onEvent(“Rosicrucian Decipher”);
// your code
FlurryAgent.onEvent(“Morse Code”);
//your code
launchMorse();
return true;
case ROSICRUCIAN_2:
FlurryAgent.onEvent(“Rosicrucian Decipher”);
// your code
All these actions with a feature are stored, and Flurry can track how many times the event occurred during the sessions of your application, and build metrics for that, as shown below in the Events section.
It is crucial to remember that unlike Web applications, the source code cannot be changed after distribution to the user—so if you wish to change your analytics provider, it may be difficult. However, it has been observed that adoption of newer versions of a mobile app is extremely fast, in fact these are often set to automatically update (with a user agreement to the clause in the ToS). One recent study on the Android site showed that within 3 weeks of releasing an app, only 3% of users continued to use the older version.
Key analytic metrics
Analytics data can be extracted using APIs or by viewing the reports online on Flurry’s website. For access using the API (http://api.flurry.com), you may need to enable it via Flurry’s developer’s configuration panel (http://dev.flurry.com). For example, an API request format given below returns summary details such as event names, total times the event occurred, total session between the specified dates (see Figure 3).
http://api.flurry.com/eventMetrics/Summary?apiAccessCode=APIACCESSCODE&apiKey=APIKEY&startDate=STARTDATE&endDate=ENDDATE&versionName=VERSIONNAME
Figure 3. Flurry online reports
A comprehensive list of important metrics is given below.
(a) Individual app’s access details
- Number of sessions, number of users new and active
- Average session length
- User spread over geographies
- User retention
- Frequency of use
- User spread across versions
- Event details
- Exception log & Errors
Note: Crash logs are a crucial metric for a developer even after the launching of the app. While most crash-logging solutions, like Flurry, have the default behaviour of sending the crash reports silently whenever the “Force Close” dialogue box appears, there are other solutions that offer ways to intercept the event causing the crash and prompt the user to fill in his comments concerning the crash. One crash logging tool for Android is ACRA Application Crash Report [8], which automatically pushes the report to a Google Docs form.
(b) Performance of your app with respect to other similar apps, and category. This is a useful benchmark for comparison.
(c) Type of hardware, software accessing your app
- Device models
- Carriers
- Firmware used
(d) Other popular metrics of your app
- Gender and age of the user (if the application uses Facebook Connect)
- Tracking stolen apps, with the knowledge of Android Market ID
- Tracking jail-broken devices accessing your app
No comments:
Post a Comment