Event Tracking with Analytics
Now that you have Analytics setup in your Android app, you might want to track some specific user actions. You might have some features that don't run on a screen or maybe you want to see how often a specific menu option is selected. Google Analytics has the ability to track specific events in side your application.
The event tracking is very easy to setup within your app assuming you've setup Analytics already. All you need to do is call the track() method on the GoogleAnalyticsTracker instance you have running in your Activity class. The track method takes four paramaters: a category, action, label and a value. The Analytics web site will sort the events by category then action or label. I have all my button clicks setup as 'UI_ACTION' category then each button name is the action and the label is the local class name of the activity. This allows me to see how often a button is clicked on a specific screen and how often a button is clicked overall.
public void onHomeClick(View v) { tracker.trackEvent("ui_interaction", "onHomeClick", this.getLocalClassName(), 0); if (this instanceof DashboardActivity) { return; } final Intent intent = new Intent(this, DashboardActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); this.startActivity(intent);}So far I've found this helpful to see what functionality is actually being used in my app. I've found out how users are navigating throughout the application. It's find of nice to see which features are being under utilized as well. Gathering this information will help you see which features need improvement and which ones you might want to eliminate.


Comments