Friday, March 25, 2011

Google Analytics Tricks for Android

I previously did a post about how to track version usage with Google Analytics, but I think I've taken that work and created something better.

I'm using the app preferences to determine if a previous version was already installed.  If it's not then the value of appPrefs.getAppVer() will be equal to a null string.  In that case I record an Application Install event with a label of the application version and a value of 1.  That increments our given version label by 1 in Google Analytics.

If our appPrefs.getAppVer() wasn't "" or "N/A" then it was an upgrade so I record an Application Upgrade with a label of the OldVersion->NewVersion and a value of 1.  That increments our given label by 1 in Google Analytics.  To explain, that means I'll get a count of upgrades from 2.9.4->2.9.5 for instance.

In the case that appPrefs.getAppVer() was equal to "N/A" that means it was a new install and the user clicked cancel on the usage agreement the 1st time.  So, we don't want to record anything.

// Display Recent Changes on 1st use of new version
if (!appPrefs.getAppVer().equals(getAppVerName())) {
 if (appPrefs.getAppVer().equals("")) {
         tracker.trackEvent("Application", "Install", getAppVerName(), 1);
      } else if (!appPrefs.getAppVer().equals("N/A")) {
         tracker.trackEvent("Application", "Upgrade", appPrefs.getAppVer().toString()+"->"+getAppVerName(), 1);
 }
 // display recent changes dialog
 tracker.trackPageView("/RecentChanges");
 appPrefs.saveAppVer(getAppVerName());
 appPrefs.saveAcceptedUsageAggrement(false);
}

// Display Usage Agreement on 1st use of new version
if (!appPrefs.getAcceptedUsageAggrement()) {
 tracker.trackPageView("/UsageAgreement");
 // display usage agreement dialog
 // negative button actions here
        appPrefs.saveAppVer("N/A");
 // positive button actions here
        appPrefs.saveAcceptedUsageAggrement(true);
}

With these tricks and a couple of others I am recording:


  1. For category "Application" I have the following events:
    1. Run -- What version is being run every time the application starts
    2. Error -- If there was an error I capture the version number that was running
    3. Upgrade -- Capture the old version and the version the user is upgrading to
    4. Install -- Capture the version of a new installation
  2. For category "Groups", "Send Message", and "Files" I have the following events:
    1. Success -- Record when something went well like, the user was able to pick a group that contained contacts, or our SMS message body contained text
    2. Error -- Record when something went poorly like, the user tried to send, but had exceeded the hourly message limit, or the SMS message had no addressees
These events are in addition to regular Page Views and should give me a lot of insight into how people are using my app.  One thing I already see a lot of: Groups -> Error -> No Records Added.  That means the user is successfully picking a group off their phone, but it either has no contacts or no contacts with a valid mobile number.  I'll have to find a way to make them more successful!

No comments:

Post a Comment