2

I have a TabActivity in android that adds 4 separate activities to a TabHost.

On the onCreate of the TabActivity I call:

tracker = GoogleAnalyticsTracker.getInstance();
tracker.start("MY UNIQUE GA CODE HERE", 10, getApplication());

And on the TabActivity onDestroy() I have

tracker.stop();

On the onResume of each activity added to the TabHost I have:

tracker = GoogleAnalyticsTracker.getInstance();
tracker.trackPageView("/ActivityTitle");

Is this the best way to do this, I have seen different methods but none consistant, eg adding the start method to each activity - but wouldn't this inflate the unique views?

Any help much appreciated Thanks in advance

Update

I have finally got some stats through and eveything seems to be working, I will reserve judgement on the time spent in app average but 'appears' to be correct. any input for best practice much appreciated. PS I get a warning in eclipse that the .start() and .stop() methods are depreciated, Googles documentation has not been updated yet so cant see a better way to do this, if you know please add. Thanks.

craigk
  • 1,294
  • 2
  • 12
  • 25

1 Answers1

0

Bit late, sorry for that. You might use the EasyTracker for multiple activities: http://code.google.com/p/analytics-api-samples/downloads/list

With this lib you can simply extend the TrackedActivity and don't have to worry about where to start/stop etc.

Ben Groot
  • 5,040
  • 3
  • 40
  • 47
  • But with EasyTracker is not possible to add tracking to the TabActivity subclass itself (or?). The tracked class has to inherit from TrackedActivity, and there's no add this inheritance relationship without modifying Android's or EasyTracker's source. – User Apr 23 '12 at 14:45