Shehabic
Shehabic

Reputation: 6877

Google Analytics (V2) Real-Time keeps reporting the user as in the main activity

My Application is formed of a Dashboard (GridView) with many Icons referring to Activities,

Whenever the user clicks on an Icon he's redirected to a new Activity but the main Activity is still open(only paused)

I'm Using Google Analytics V2.

Wherever the user goes through the App, The Real-Time in Google Analytics keeps reporting the user as if he's in the main Activity.

I tried to add the G.A. code to onPause and onResume but still it reports that the user is in the Main Activity.

Here's the code I'm using:

  @Override
  public void onStart() {
    super.onStart();
    if(UserFunctions.getGASetting(getBaseContext())){
        EasyTracker.getInstance().activityStart(this); // Add this method.
    }
  }

  @Override
  public void onStop() {
    super.onStop();
    if(UserFunctions.getGASetting(getBaseContext())){
        EasyTracker.getInstance().activityStop(this); // Add this method.
    }
  }

  @Override
  public void onPause() {
    super.onPause();
    if(UserFunctions.getGASetting(getBaseContext())){
        EasyTracker.getInstance().activityStop(this); // Add this method.
    }
  }

  @Override
  public void onResume() {
    super.onPause();
    if(UserFunctions.getGASetting(getBaseContext())){
        EasyTracker.getInstance().activityStart(this); // Add this method.
    }
  }

Upvotes: 2

Views: 957

Answers (1)

Lorne Laliberte
Lorne Laliberte

Reputation: 6311

Did you set ga_autoActivityTracking to true in your analytics.xml file? See the docs for EasyTracker.activityStart(Activity) which says:

Track the start of an Activity, but only if mIsAutoActivityTracking is true. This method will start a new session if necessary, and will send an empty event to Google Analytics if mIsAutoActivityTracking is false to ensure proper application-level tracking.

It sounds to me like it's sending an empty event because you have ga_autoActivityTracking ommited or set to false.

Upvotes: 1

Related Questions