Using Google Analytics within an Android app


Published on

Using Google Analytics within an Android app in 3 easy steps

Using Google Analytics within an Android app

  1. 1. April 2nd Living Tomorrow Brussels within Android applications/games
  2. 2. Quick introduction by cousinHub [email_address] cousinHub22 within Android applications/games
  3. 3. www . appbrain . com
  4. 4. Why ? How ? How to get started ? For example … within Android apps/games
  5. 5. <ul><li>Version tracking of your applications </li></ul><ul><li>Fun & provides better insight into your users : Map Overlay, Content Overview, Visitors’ screen resolutions, language, etc. </li></ul><ul><li>Improve the application : make s it easy to see how people are using specific parts of Android applications => feedback loop </li></ul><ul><li>Tracking Referrals : The Android 1.6 OS release supports the use of a referrer URL parameter in download links to the Android Market. </li></ul>WHY ? within Android apps/games
  6. 6. <ul><li>As with websites, there are two basic categories of user interaction you can track : pageviews and events . </li></ul><ul><li>Since mobile apps don't contain HTML pages, developers simply determine when their apps should trigger P ageview requests. Google Analytics then aggregates this data in the Content reports to display the number of visits, session length and bounce rates. The data gives insight into how your users interacted with the app. </li></ul><ul><li>Developers can also track visitor actions that don't correspond directly to pageviews using  Event Tracking . These user actions can include views of embedded videos, button clicks, downloads and more. App developers can then use this data to understand which features are most popular and inform decisions about which features should be promoted or prioritized for further development. </li></ul>within Android apps/games
  7. 7. <ul><li>Step 1 : a dd  libGoogleAnalytics.jar  to the project's  /libs  directory </li></ul><ul><li>Step 2 : create a new website profile into Analytics </li></ul><ul><li>Step 3 : code & don’t forget the manifest: </li></ul><ul><li>a dd the following permissions to  the AndroidManifest.xml : </li></ul><ul><li><uses-permission android:name=&quot;android.permission.INTERNET&quot; /> </li></ul><ul><li><uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /> </li></ul>HOW ? within Android apps/games
  8. 8. Step 1 <ul><li>Download & unzip the Analytics SDK for Android: </li></ul><ul><li> </li></ul><ul><li>Add External JAR to your project : </li></ul><ul><li>Project> Properties> Java Build Path> Add External JARs> libGoogleAnalytics.jar </li></ul>within Android apps/games
  9. 9. Step 2 <ul><li>C reate a free account at </li></ul><ul><li>(or use your current account) and create a new website profile in that account using a fake but descriptive website URL : </li></ul><ul><li>http://mymobileapp. yourANDROIDapp .com </li></ul><ul><li>Once you create the profile, write down or keep a copy of </li></ul><ul><li>the web property ID that is generated for the newly-created profile : </li></ul><ul><li>a  Web property ID is also known as the UA number of your tracking code and looks like  UA-xxxxx-yy </li></ul>within Android apps/games
  10. 10. Step 3 <ul><li>Let’s code ! First, o btain the tracker singleton by c alling  </li></ul><ul><li>GoogleAnalyticsTracker.getInstance( ) </li></ul><ul><li>Then call its  start()  method, passing the web property ID </li></ul><ul><li>and activity being tracked. </li></ul>within Android apps/games
  11. 11. Step 3 <ul><li>Track pageviews and /or events … </li></ul>within Android apps/games
  12. 12. Step 3 <ul><li>Batching Hits : to save on connection and battery overhead, you can dispatch hits manually, or at specifi time intervals by using the  dispatch()  method of the tracker object. It is recommended that you reduce overhead by bundling tracker dispatches with other HTTP requests made by the application : </li></ul><ul><li>Stop the tracker when it is no longer needed : </li></ul>within Android apps/games
  13. 13. Wait 24 hours to see your first data coming through in Analytics … ! within Android apps/games Step 1 : JAR file - 1’ max Step 2 : Web property ID - 1’ max Step 3 : code - 3’ max (6 lines min) <ul><li>No excuse really not to do / try it ! </li></ul><ul><li>In 5 minutes, you’re done ! </li></ul>
  14. 14. For example …
  15. 16. HTC Tattoo Nexus One
  16. 17. [Menu] key
  17. 18. Inviting users to use the [Menu] key has boosted traffic on the Belgian Apps page…
  18. 19. <ul><li>Get started using Google Analytics to understand and optimize how people use your Android mobile app ! </li></ul><ul><li>C heck out the SDK and technical docs here : </li></ul><ul><li>h ttp:// </li></ul><ul><li>mobileAppsTracking.html </li></ul><ul><li>Have FUN </li></ul>within Android apps/games How to get started ?