Android Application Tracking through Google Analytics

By Dipali Thakkar | 09.12.2011

We’re in the era of mobile, where there are 5.3 billion mobile subscribers worldwide and these numbers are increasing very rapidly. Most of the mobile subscribers are using  mobile apps for either shopping or for accessing social networking sites or playing games or listening online songs and etc.

There were 300,000+ applications downloaded 10.9 billion times in 2010 [December 2010] only as per research by IDC. There are so many mobile apps in the market whether it’s for iPhone or Android or Blackberry or Symbian based mobile phones and Windows OS based smart phones.

There are so many mobile development companies or mobile developers who build mobile applications but after wards they don’t know the effectiveness of their application in terms of how many persons actually using it after downloading, what’s bounce rate, from which mobile handset your application is being accessed and so many factors. For that you should start tracking application using web analytics tool i.e. Google Analytics. Here I’m going to explain google analytics implementation for following mobile applications.

  1. Android
  2. iPhone
  3. Blackberry

Android Application Tracking through Google Analytics in just 3 Steps

Step 1 - Firstly you’ll have to download Google Analytics SDK for Android, You can download it from here, then extract file and add libGoogleAnalytics.jar to your application’s /libs directory. And add the below  permissions to your application’s AndroidManifest.xml manifest file:

  • <uses-permission android:name=”android.permission.INTERNET” />
  • <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />

Step 2 - You’ll have to setup new web property in google analytics, most likely fake profile but with full URL  like http://myapp.mywebsite.com, then note down UA number of your tracking code and looks like UA-xxxxx-yy.

Step 3 – Implementing google analytics in android application, you can track below activities as per your android application,

  • Page View Level
  • Event Level
  • Custom Variable
  • Ecommerce Tracking

For Instance, We’ve implemented page view level and event tracking of google analytics for My Music Player android app. It has 3 to 4 different tabs i.e. Albums, Artists, Songs and Playlist. We’ve implemented page view level implementation for tracking page view details of different tabs / pages as with reference to below image.

Artist Page of My Music Player

Let’s start Google Analytics Tracking for Android Application

Page view level implementation

Through page view level implementation of application, you can get idea about unique page views of your application’s pages as like traditional website, like unique page view for setting section or help section.

For getting page view level information you’ll have to implement below standard code to across all the tabs or classes or pages of your application, as like we implement google analytics for website.

   tracker = GoogleAnalyticsTracker.getInstance();
    // Start the tracker in manual dispatch mode...
    tracker.startNewSession("UA-YOUR-ACCOUNT-HERE", this);
Replace your UA account number with “UA-YOUR-ACCOUNT-HERE” in above code.

// ...alternatively, the tracker can be started with a dispatch interval (in seconds).
//tracker.startNewSession("UA-YOUR-ACCOUNT-HERE", 20, this);

You can also set tracker for dispatching interval by adding seconds in above code.

Event tracking implementation

Through event tracking implementation, you can get idea about which actions i.e. play, pause or stop has been taken in your android application through applying event tracking in google analytics.

For Instance, we’ve implemented event tracking for tracking which action has been taken in My Music Player App i.e. play or pause or stop or share it with Facebook or Twitter with reference to below image.

Now Playing Section of My Music Player

For event tracking implementation, you’ll have to add below code across the classes or functions of where buttons are called

          tracker.trackEvent(
            "Clicks",  // Category, i.e. Player Buttons
            "Button",  // Action, i.e.  Play
            "clicked", // Label    i.e. Play
            77);       // Value,

Tracking Tabs / Pages / Classes of Application

If you want to track different sections / tabs of your application, then you should tracker.trackpaview function over the sections. You can see the below example,

// tracker.trackPageView("/help"); to track someone looking at the help screen.
// tracker.trackPageView("/setting"); to track someone looking at the settings screen.
// tracker.trackPageView("/Now Playing"); to track someone using a now playing screen.
<h3>Dispatching Interval</h3> 

if you haven’t called automatically dispatch event tracker then you should implement below manually dispatch tracker at the end of the event tracking code. You can see the below example of it.

// manually start a dispatch, not needed if the tracker was started with a dispatch interval.
        tracker.dispatch(); 

Implementation of Stop Session

You can terminate the session if you don’t need it longer. It’s necessary to add below code on destroy class for terminating the session.

// Stop the tracker when it is no longer needed.
tracker.stopSession();

Google Analytics Reports for Android Applications

After google analytics implementation for android application successfully, you can view the analytics report for your application in your google analytics account. You can see the Top content Section report that includes bounce rate and unique page views for the android application in below image.

Google Analytics Top Content Report for Android Application

You can view page level performance of your android application in google analytics with detailed information like bounce rate, unique page views, avg. time on site etc in below image.

Google Analytics Page level performance Report for Android Application

In next series of mobile apps tracking blog post, I’ll be covering iPhone Application Tracking through Google Analytics. Stay tuned here for more updates on Google Analytics Implementation.

Feel free to share your suggestion and feedback.

Dipali

Dipali

Dipali Thakkar is working as Technical Associate at Tatvic. She has more than 4 years of experience in SEO, PPC and Social Media. Google Plus Profile:

More Posts - Website

Follow Me:
TwitterFacebook

  • http://twitter.com/aaronlintz Aaron Lintz

    Crazy clever work! That is a great way to learn how people actually use your app. I had no idea that was possible.

  • http://www.tatvic.com Dipali

    Hey Aaron,

    Thanks for your appreciation, It’s easy to implement google analytics for android apps.

  • 1988 Kalpesh

    thanks for the detail but can you tell me how track Session time, Unique and new Visitors

  • Vkonnect App

    this is showing the statistics on web(on analytics account). what if i want to show it on my android phone?? cab u help me for this?

    • http://www.tatvic.com Dipali

      Hello,

      You can check google analytics data on your android phone by installing analytics application. check this URL, https://play.google.com/store/search?q=google+analytics&c=apps

      Hope this will help you.

    • Dipali Thakkar

      Hello, 
      You can check google analytics data on your android phone by installing analytics application. check this URL,  https://play.google.com/store/search?q=google+analytics&c=apps 

      Hope this will help you. 

  • http://newsresults.in/ Mayurpatel2008

    i was try to install it but not working anybudy guide me….

  • Imag

    just a thought, but does bounce rate really make any sense on an app (other than single page apps, of course).

    I mean, how do you bounce on some random subpage, that you can’t access from outside the app structure itself?

  • http://www.dcgla.com/private-cloud-solutions/cloud-computing-los-angeles.html cloud hosting los angeles

    So far I never heard about Google analytic for Android application..It is absolutely new for me…After read entire post step by step and all info are blow in my mind. I promise you that  once time i will be try it..Thanks for sharing…

  • Rajeesh Ramakrishnan

    i’m creating a radio, how can i get the visited station duration. ie; how long a particular user listened a station.

    • http://www.tatvic.com Suketu Parikh

      You may keep a timer on start of a radio and once the user change’s the radio station you may send event tracking call with recorded duration.

  • Pingback: Android Application Tracking through Google Analytics - Welcome to LocalAndroidApps.com | Welcome to www.LocalAndroidApp.com