|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.android.apps.analytics.easytracking.EasyTracker
public class EasyTracker
EasyTracker is a class designed to easy the burden of adding tracking code to your application. Simply add this class to your application and extend TrackedActivity instead of Activity for each Activity in your application.
This class is designed to be used from a single Thread. Use on the Main UI Thread is acceptable.
Note that all of your Activities must extend TrackedActivity (or an equivalent Activity, like TrackedListActivity instead of ListActivity) for this Class to properly track application usage and time. If you have an Activity Class that doesn't extend one provided in this package, you can create one by copying TrackedActivity and having it extend the Activity you want. For example, if you have an Activity subclass called FragmentActivity, simply create a class called TrackedFragmentActivity and have your classes extend that instead of FragmentActivity. The code for TrackedFragmentActivity should be the same as the code in TrackedActivity.
You can turn on tracking by providing a String resource of the name ga_api_key with a value of your account id (form UA-12345-6). You can provide various parameters as String, Bool or Integer resources (such as sampleRate) as well. Just use the proper type for the parameter (String for String, Bool for boolean and Integer for int).
If you want to track your Activities as well as the application, you can add the Bool resource ga_auto_activity_tracking and give it a value of "true".
| Field Summary | |
|---|---|
static String |
LOG_TAG
|
| Method Summary | |
|---|---|
void |
addItem(com.google.android.apps.analytics.Item item)
Adds an Item to the Transaction identified by Item.orderId. |
void |
addTransaction(com.google.android.apps.analytics.Transaction transaction)
Adds a Transaction to be sent to Google Analytics. |
void |
clearTransactions()
Clears all pending Transactions and Items from the internal queue. |
void |
dispatch()
Dispatch up to 30 queued hits to the Google Analytics servers, but only if another dispatch is not in progress. |
static EasyTracker |
getTracker()
|
void |
setContext(Context ctx)
Sets the context to use to the applicationContext of the Context ctx. |
void |
setReferrer(String referrer)
Set the campaign referral to the values in the input. |
void |
startNewSession()
Start a new session using the parameters stored in the EasyTracker Class. |
void |
stopSession()
Stops the automatic dispatch from continuing to run. |
void |
trackActivityRetainNonConfigurationInstance()
Track Activity restarts due to configuration changes (i.e. |
void |
trackActivityStart(Activity activity)
Track the start of an Activity, but only if autoActivityTracking is true. |
void |
trackActivityStop(Activity activity)
Track the end of an Activity and/or application. |
void |
trackEvent(String category,
String action,
String label,
int value)
Track an Event. |
void |
trackPageView(String name)
Track a pageview, which is analogous to an Activity. |
void |
trackTransactions()
Sends all the pending Transactions and Items to dispatch. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String LOG_TAG
| Method Detail |
|---|
public static EasyTracker getTracker()
public void setContext(Context ctx)
ctx - the Context to use to fetch the applicationContextpublic void trackActivityStart(Activity activity)
activity - the Activity that is to be trackedpublic void trackActivityRetainNonConfigurationInstance()
Note that the GoogleAnalytics SDK supports Android versions back to 1.5. The onRetainNonConfigurationInstance method is deprecated in Android 3.0, but its replacement is only supported in Android 2.1 and beyond.
public void trackActivityStop(Activity activity)
activity - the Activity that is to be trackedpublic void addItem(com.google.android.apps.analytics.Item item)
item - the Item to addpublic void addTransaction(com.google.android.apps.analytics.Transaction transaction)
transaction - the Transaction to addpublic void clearTransactions()
public void dispatch()
public void setReferrer(String referrer)
referrer - the campaign referral information to setpublic void startNewSession()
public void stopSession()
public void trackEvent(String category,
String action,
String label,
int value)
category - the category of the eventaction - the action of the eventlabel - the label of the event, can be nullvalue - the value of the eventpublic void trackPageView(String name)
name - The name of the Activity or view to be tracked.public void trackTransactions()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||