Google Analytics in Android app - dealing with multiple activities

后端 未结 7 2164
忘了有多久
忘了有多久 2020-11-28 18:42

I was pretty excited to see how easy it is to set up Google Analytics with my app, but the lack of documentation has me sitting with a few questions. The only information th

相关标签:
7条回答
  • 2020-11-28 19:15

    I did a time based split between visits in my app, working like this:

    I've build a wrapper singleton Tracker object for the GoogleAnalyticsTracker where i keep the last time something got tracked. If that time's more then x seconds i treat it as a new visit.

    Of course this is only useful if you track everything in your app, and may not be the best solution in every situation, works well for my app though.

    It only supports trackPageView, but setCustomVar and trackEvent should be easily implemented..

    Anywhere you need to track something just add the line:

        Tracker.getInstance(getApplicationContext()).trackPageView("/HelloPage");
    

    I usually do it in the onResume of an activity

    Tracker gist

    0 讨论(0)
提交回复
热议问题