7

As my app, the count of session was about 1,000~2,000 when I was using Google Analytics Android SDK v3. enter image description here

But when I updated from v3 to v4, the count of session grows to 4,000~5,000. enter image description here

This is the global_tracker.xml:

<?xml version="1.0" encoding="utf-8"?>

<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>

<!-- The screen names that will appear in reports -->
<string name="ga_trackingId">xx-xxxx-xx</string>

And this is what I have done in the Application.java file:

public class ABCApplication extends Application {
...
private static Tracker t;

...
public synchronized Tracker getTracker() {

    if (this.t == null) {
        GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
        this.t = analytics.newTracker(R.xml.global_tracker);
    }
    return t;

}}

And this is the MainActivity.java file:

public class MainActivity {

@Override
public void onStart() {
    super.onStart();

    Tracker t = ((ABCApplication) this.getApplication()).getTracker();
    t.send(new HitBuilders.EventBuilder().setCategory("app").setAction("app_launch")
            .setLabel("start_google_analytics").build());
}

...}

What's the reason of this problem? And how can I solve it?

3
  • Did the number of active user increased as well or only the number of sessions changed?
    – djabi
    May 11, 2015 at 20:01
  • @djabi Only the number of sessions changed, the number of active user did not increase.
    – nnezhxw
    May 12, 2015 at 0:41
  • @nnezhxw did you got any solution??
    – kundan roy
    Oct 6, 2016 at 11:39

3 Answers 3

6

As we investigated, the root cause of this issue is Activity auto tracking. When Activity auto tracking is off, GA will close user session, after the 30 minutes from last event is gone. If Activity auto tracking is on, GA will end session after the app goes into background or user exit the app. Then launching the app within short period of time will create a new session in GA.

1
  • Thanks a lot, your comment helps me very much. Sep 17, 2015 at 14:56
1

Maybe it has something to do with your timeout setting

Try adjusting this in your xml:

<resources>
  <integer name="ga_sessionTimeout">300</integer>
</resources>

https://developers.google.com/analytics/devguides/collection/android/v4/sessions

0

Add this to your manifest:

<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
     dispatching on non-Google Play devices -->
<receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
          android:enabled="true">
  <intent-filter>
    <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
  </intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.AnalyticsService"
         android:enabled="true"
         android:exported="false"/>

I've just done some preliminary testing, but after I added this it seems to be properly reporting session and duration again. Code snippet taken from: https://developers.google.com/analytics/devguides/collection/android/v4/#manifest

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.