Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ga_autoActivityTracking= true: exclude specific activities from being reported

[For Android Google Analytics v4]

Is there a way for specific activities to not be reported (Sending hit to service) when ga_autoActivityTracking = true?

I was thinking of turning ga_autoActivityTracking false at onStart() and true again at onStop() in the specific activities. If that possible would someone be as kind as in providing a sample code. Other approaches are also most welcome.

Thank you.

like image 898
MPS Avatar asked Sep 18 '14 05:09

MPS


1 Answers

When using autoActivityTracking you can not exclude some Activities from the report unfortunately. The only way to do that is to disable automatic activity tracking and manually send screen view from Activity.onStart():

tracker.setScreenName("screen name");
tracker.send(new HitBuilders.ScreenViewBuilder().build());

You can not turn off auto activity tracking from onStart() as the callback list is captured by Android before the callbacks are made. Any change in the list will not affect the list of registered callback for this onStart(). Unfortunately disabling the auto activity tracking from onStart will not work.

like image 163
djabi Avatar answered Sep 29 '22 00:09

djabi