Nimit Pattanasri
Nimit Pattanasri

Reputation: 1602

A more advanced example of Google Analytics EasyTracker library (on Android)

In an example provided by Google (http://code.google.com/p/analytics-api-samples/), it doesn't show how to customize page tracking. For example, where in the code should I call something like:

Tracker.getInstance(getApplicationContext()).trackPageView("/MyActivity/"+myVariable);

Does anyone has experience on using this library? I also couldn't find its documentation.

Upvotes: 2

Views: 6593

Answers (3)

IgorGanapolsky
IgorGanapolsky

Reputation: 26821

You should follow Google's instructions on setting up screen tracking: Screen Tracking

Basically, you can specify your app's screens (activities) that you want to be automatically tracked in your analytics.xml file.

Upvotes: 1

goncalossilva
goncalossilva

Reputation: 1860

All you need to do is to make sure your activities inherit from TrackedActivity, and they will be automatically tracked (considering you also enabled ga_auto_activity_tracking).

If you want to get the tracker object—to record events, for instance—just call EasyTracker.getTracker().

Edit: After a small discussion in the comments with Georgy Gobozov, I should add that you should not use EasyTracker before your onStart() method, where you call super.onStart(). It's on TrackedActivity's onStart() method that it calls trackActivityStart(), which starts a new session.

Upvotes: 4

CrayonViolent
CrayonViolent

Reputation: 32532

you would place that in the part of your code that corresponds to what you would call a page view or event in your app.

For instance, if you wanna track how many people look at a help menu, place it in the code that is invoked whenever the help menu button is pushed, or in the code that displays the help menu (and have the myVariable variable be something like "help menu").

Upvotes: 0

Related Questions