To start with Google Analytic, We must have have an Google account & We need to get a unique key that will be used in code to trace events. Follow below mentioned process to achieve it.
At Web side (Google):
1. Create an account on http://www.google.com/analytics/
2. Select Setting button & add a new Account
3. Provide Account name, URL, Time Zone & Press "Create Account"
4. Now you will get a "Web Property ID"; this key we need to use at code level.
5. Now download the required lib from below path
http://code.google.com/apis/analytics/docs/mobile/download.html
At code side:
Set Environment (for Eclipse):
1. Get libGoogleAnalytics.jar
2. Go to Properties - > Java Build Path & select Add external jar.
3. Provide the path of libGoogleAnalytics.jar & add it.
Changes in Code:
1. Add permission in AndroidManifest.xml manifest file.
2. Start session in onCreate & End Session in onDestroy
public void onCreate()
{
super.onCreate(savedInstanceState);
tracker = AnalyticsTracker.createInstance();
tracker.start("<GOOGLE ANALYTICS ACCOUNT ID>", this);
}
public void onDestroy()
{
super.onDestroy();
// manually dispatch tracker
tracker.dispatch();
// Stop tracker.
tracker.stop();
}
To Trace Events:
tracker.trackEvent( Category, Action, Label, Value);
e.g. tracker.trackEvent("Category Name", "Action Name", "
To Trace Page Views:
tracker.trackPageView("
Useful Link:
http://code.google.com/apis/analytics/docs/mobile/android.html