Google Analytics now can integrate into your Google Play Developer console and show you statistics how your application is used by your users. It gives you:
- better insight on how it is perceived by your customers, by showing most recent opened screens and user journeys
- an overview of how often your app is used
- overview how many times your app is being watched in Google Play store
- reports on unhandled exceptions
- reports on inapp purchases
- times spent on actions
- and more to read here
1. Download Analytics Services SDK
You can get the library from here. Unfortunately it is not yet available in any maven repository, so you have to download jar file and put it in libs directory.
2. Set up new Google Analytics app property and view (profile)
This will give you tracking ID that you will use further in application code. Now the coding part is left.
3. Add permissions to AndroidManifest.xml file
If your app is not using these, adde them:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4. Add tracker methods
These EasyTracher class methods are basic ones that will track your activity start and stop events. Add this code to your Activity’s onStart() method:
and this method to onStop():
5. Create your analytics.xml file
This file manages Tracker settings. Put this file in res/values folder. Here is the simpliest file content that will provide tracking ID from step 2, enable Activity tracking and reporting uncaught exceptions. Two simple items to track, however very useful!
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes"> <string name="ga_trackingId">UA-44734016-1</string> <bool name="ga_autoActivityTracking">true</bool> <bool name="ga_reportUncaughtExceptions">true</bool> </resources>
Note that this file contains also warning suppressions. Warning are generated by lint, and are about using dashes (‘-‘) in xml file.
Now your app is ready to send data to Google Analytics. I’ll publish an update with analytics included and let you know how it works! Stay tuned and use PayTogether app!
Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality