Event Tracking - Android SDK v2 (Legacy)

This developer guide describes how to measure events in your app using the Google Analytics SDK for Android v2.


Events are a useful way to collect data about a user's interaction with interactive components of your app, like button presses or the use of a particular item in a game.

An event consists of four fields that you can use to describe a user's interaction with your app content:

  • String Category
  • String Action
  • String Label
  • Long (Optional) Value


To send an event to Google Analytics, call sendEvent(). For example, to measure a button press, you might add this code to OnClickListener's onClick method:

public void onClick(View v) {
  // Where myTracker is an instance of Tracker.
  myTracker.sendEvent("ui_action", "button_press", "play_button", opt_value);
  ... // Your other click handling code.