Thursday, April 21, 2011

How to test Google Analytics for Android

Time ago I wrote how to integrate Google Analytics into your Android application. The integration and usage it is pretty simple but the testing part is really terrible. I said that time that you can see the data in your Google Analytics account only after almost a day you posted the events. This was ridiculous, waiting one day to see your results and data just to check it is fine was just a waste of time so started digging and fingig out where these data is stored because it must have some kind of storage so later when you dispatch the data the framework looks for this data and posts it online.

Indeed, my supposition was true. As it turns out when you configure you Google Analytics account in your android application, it creates a new DB in your package folder. Inside this Data Base there are a bunch of tables but the one that stores your page views and events is named events. If you want to test the data you are collecting, these are the steps you need to do:

adb shell
cd data/data/<your.package.name>/databases
sqlite3 google_analytics.db
This last command will open the Google Analytics data base and once there you can see all the tables by executing .schema. So every time you record a page view or event a new row will be inserted in the events table. This table has a lot of columns but you can execute .schema events to see all of them and its data types so you can query the ones that you care about to test your application.

Happy coding.

2 comments:

  1. I'm using Android 4.4.2, and I'm getting permission denied error while trying to access the data folder.

    ReplyDelete