This is how I designed my Google Analytics to work on my app:
Every activity extends TrackedFragmentActivity or any other fragmentActivity which extends TrackedFragmentActivity.
TrackedFragmentActivity is:
public class TrackedFragmentActivity extends SherlockFragmentActivity {
GoogleAnalyticsTracker tracker;
public void startAnalytics(String pageName) {
tracker = GoogleAnalyticsTracker.getInstance();
tracker.startNewSession("UA-CODE-HERE", this);
tracker.trackPageView(pageName);
tracker.dispatch();
}
}
and every activity has a super.startAnalytics("pagenameHere") call in the onCreate.
Now, every activity gets properly tracked and everything, but duration-related data are completely messed up:
Pages / Visit: 1.07
Avg. Visit Duration: 00:00:00
Bounce Rate: 94.63%
I was calling stopTracker() onDestroy and I though it was its fault for this behavior, therefore I tried to remove it, but I get exactly the same problem.
Any idea what could be causing this?
The main problem was calling this method:
tracker.startNewSession(“UA-CODE-HERE”, this);
every time a new activity was loaded. So I just added a very stupid static boolean to call the method only the first time. Does anyone have a better solution?
the new code is: