0

We have an existing app that we want to add Analytics to.

This link: https://developers.google.com/analytics/devguides/collection/android/devguide shows how to do so with a single Activity. It mentions that apps with multiple Activities should use the EasyTracker library. Although I couldn't find any direct documentation, looking through the samples and searching SO suggests that to use EasyTracker, Activities should extends TrackerActivity.

However, we're using the compatibility library for Fragment support, so most Activities in the App already extend FragmentActivity, and therefore cannot extend TrackerActivity.

Finding this post: Google Analytics in Android app - dealing with multiple activities, the answerer provides an alternative for this situation. When I start to implement the solution posted there, Eclipse gives a warning that the start and stop methods of GoogleAnalyticsTracker have been deprecated.

Unable to find documentation, I assume that start has been replaced with startNewSession, and stopSession should be used instead of stop, but am not sure. Will the solution linked above still work if I make those changes? Is there an alternative approach available for Apps with multiple Activities, that can't subclass TrackerActivity?

TYIA.

Community
  • 1
  • 1
momo
  • 3,885
  • 4
  • 33
  • 54
  • 1
    Well, there's nothing really that would refrain you from implementing an `EasyTrackerFragmentActivity` that you can then extend from. In fact, it'll be little more than four lines of actual code. Just have a look at the source code of [`EasyTrackerActivity`](https://code.google.com/p/analytics-api-samples/source/browse/trunk/src/tracking/mobile/android/EasyTracker/Library/src/com/google/android/apps/analytics/easytracking/TrackedActivity.java) – MH. Jul 12 '12 at 20:51
  • @MH. +1 - thanks for the link - as you said, pretty simple implementation. i'll leave this open though in case anyone knows if I can replace those deprecated methods and successfully use the linked solution – momo Jul 12 '12 at 20:59

1 Answers1

0

Turns out the solution linked above does work well, and the deprecated methods can be replaced as per my comment here.

Community
  • 1
  • 1
momo
  • 3,885
  • 4
  • 33
  • 54