How to Track your Android App through Google Analytics
In this blog post, I would like to show how to track your Android Application using Google Analytics in Android.
Step By Steps:
- Go to https://www.google.com/analytics/, login, and select one of your accounts. Then, click on Admin in the navigation bar.
- Click on the list of properties, and choose “Create new property” under property tab.
-
You have now to indicate that the new property will track data from a Mobile app. Give it a name, a timezone, and an industry category related to your app.
- Get the Tracking ID, something like UA-xxxxxxxx-y.
- Download Google Analytics library .jar file from here.
- Add Google Analytics library to your Android project libs folder and right click, select add to build path.
- Update the AndroidManifest.xml file with Internet Permission.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- Update activities code with this code snippet:
@Override public void onStart() { super.onStart(); EasyTracker.getInstance(this).activityStart(this); // Add this method. } @Override public void onStop() { super.onStop(); EasyTracker.getInstance(this).activityStop(this); // Add this method. }
- Create a new xml file under values folder, analytics.xml and copy paste this code:
<?xml version="1.0" encoding="utf-8" ?> <resources> <!--Replace placeholder ID with your tracking ID--> <string name="ga_trackingId">UA-xxxxxxxx-y</string> <!--Enable automatic activity tracking--> <bool name="ga_autoActivityTracking">true</bool> <!--Enable automatic exception tracking--> <bool name="ga_reportUncaughtExceptions">true</bool> </resources>
That’s it. Now just wait for 24 to 48 hours. and it would show all the events and analytic for the App you had registered
Hope this helpful. Your valuable comments are always welcomed. It will help to improve my post and understanding.
Download Source Code from here.
Related Posts
durga chiranjeevi
Latest posts by durga chiranjeevi (see all)
- Sharing Application Data Between Two Android Apps – Part III - April 8, 2015
- Sharing Application Data Between Two Android Apps – Part II - April 8, 2015
- Sharing Application Data Between Two Android Apps – Part I - April 8, 2015