Home » Android » Google Analytics for Android v4 – Automatic Screen Measurement not working?

Google Analytics for Android v4 – Automatic Screen Measurement not working?

Posted by: admin June 15, 2020 Leave a comment


I finally got around to trying out Google Analytics v4. Actually, it’s my first time using GA at all, so I’m not quite as familiar with the way things are done.

In any case, I managed to get the MobilePlayground sample to build and it mostly works – except for the Automatic Screen Measurement feature

The XML config file in the sample is just like in the docs, so I shouldn’t have to edit anything to get that part to work. But I don’t see those screen views in the GA console.

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

    <!-- The screen names that will appear in reports -->
    <screenName name="com.google.android.gms.analytics.samples.mobileplayground.ScreenviewFragment">
        AnalyticsSampleApp ScreenView
    <screenName name="com.google.android.gms.analytics.samples.mobileplayground.EcommerceFragment">
        AnalyticsSampleApp EcommerceView

(Nevermind the fact that there doesn’t seem to be a class called “com.google.android.gms.analytics.samples.mobileplayground.ScreenviewFragment”)

I also tried it out on my own app and still no screen views are showing up. Even those GA log level is set to Verbose, I don’t see anything in LogCat relating to GA when I visit those activities that I configured for automatic screen measurement. Though I see plenty of GA debug output when I visit an activity for which I’m manually calling the Tracker to send screen views.

So I guess my question is does anyone have this Automatic Screen Measurement feature working in Google Analytics v4? And if so, what else do I need to do to get “automatic” measurement to work?

How to&Answers:

Well, a little more searching on SO and I found a workaround here

It sounds like there’s a bug in GA. But making a call to enableAutoActivityReports on GoogleAnalytics class seems to take care of it. Once I did that in my application class, the automatic screen views showed up, and the screen names were correctly mapped as configured in my tracker XML.

Note that enableAutoActivityReports says it’s only for API 14 (ICS) and above. Not sure what Gingerbread is supposed to do.


I am the original answerer from the question that kevin linked to.

A few things:

  • The sample app is a little misleading because it uses fragments and enableAutoActivityReports only works with Activities. I would like to fix it at some point but not sure when I’ll be able to.
  • If you would like auto activity to work on all the devices, you’ll have to call reportActivityStart from onStart of each activity. I know it is tedious but given the constraints, not sure what else can be done. If you do call reportActivityStart, it will do the right things and be a noop for newer devices.

feel free to ask more questions.