There appear to be many issues with using Google Analytics (libGoogleAnalytics.jar) for Android.
- GoogleAnalyticsTracker keeps a static reference to a GoogleAnalyticsTracker instance, which in turn keeps a strong reference to the Context passed into start(), which prevents that context from ever getting garbage collected (basically, a memory leak).
- It is unclear how to properly track a user's session across activities. Calling GoogleAnalyticsTracker.start() in each activity's onCreate() results in a new session for each activity. Moving start()/stop() to only a single "master" activity doesn't work, because subsequent activities may try to track pageviews after stop() has been called, resulting in NullPointerExceptions. And moving the start() call to Application.onCreate() and stop() to Application.onTerminate() results in: A) very long-lived sessions since Application.onTerminate() is infrequently called, and B) spurious session starts if you have things like background Services that run periodically.
- Fails to log events with names that contain spaces.
The documentation for the library is sparse and doesn't show an example of a multi-activity application.
Looking around StackOverflow and other sites, I've been trying to get a sense of best practices when using GA for Android, especially as pertain to the above issues. Has anyone gotten this figured out?
Also, what other issues are there that I haven't mentioned above?