Thursday, August 16, 2012

Google Analytics for Android

There are actually 2 versions of the SDK:

- For the V1 read the official documenation at https://developers.google.com/analytics/devguides/collection/android/devguide
My experience/advise after you read the official documentation:
1. Download the source code of the EasyTracker library, not the .jar file. Why? because maybe you would want to debug it, etc.
2. Import into your IDE the source code of EasyTracker as a Project and add the googleanalyticslib.jar to this project. Make this project an Android library and reference it from your App project.
3. Note that you must specify the settings as a ressource under you values folder. The readme file tells you about the variables that can be set and the data type, be sure to use <bool> and not <string> for boolean values, otherwise the settings will not be apllied.
4. If you want to track an activity you only need to extend the class from TrackedActivity or TrackedListActivity. For MapActivity create a class by yourself with the name MapTrackedActivity, and copy/paste the code from TrackedActivity.
5. Make sure to set <bool name="ga_auto_activity_tracking">true</bool> otherwise only the visits to your app will get tracked but not each activity.
6. On GoogleAnalytics under Content->Overview you can see a report about the activities being visited.

- The V2 of the SDK will merge the EasyTracker and googleanalytics libs. An extra .xml file will be used to set the settings and the analytics website will be customized for Apps, and not only for websites like now.

No comments:

Post a Comment