8

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>
    <screenName name="com.google.android.gms.analytics.samples.mobileplayground.EcommerceFragment">
        AnalyticsSampleApp EcommerceView
    </screenName>

(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?

Kevin
  • 526
  • 4
  • 12
  • 3
    I ran into the same problem yesterday. It doesn't help that the analytics v4 docs are unusually vague and confusing, or that the example is contrived and arbitrary. I gave up and ended up manually firing the events. It would also be nice if the example showed how to handle activity rotations and cases like that, but it only shows how to fire events when a button is pressed. Not very helpful. – aleph_null May 16 '14 at 01:10
  • I wholeheartedly agree. This v4 doesn't quite seem ready for primetime yet. The basic MobilePlayground example took way too much effort to get working when I'd expect it to work right out of the box. Someone really needs to QA their Getting Started guide. – Kevin May 16 '14 at 06:22
  • Thanks for the feedback. we'll try to get the sample fixed soon. No ETA though. – Avi May 17 '14 at 01:26
  • 1
    Avi, could you please escalate this fix? Developers are wasting precious time because of it. It can't be that hard for a company that has enough spare resources for doodles:-) Thank you – NightKnight on Cloudinsidr.com Jun 11 '14 at 06:23

2 Answers2

9

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.

Community
  • 1
  • 1
Kevin
  • 526
  • 4
  • 12
3

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.

Avi
  • 2,373
  • 17
  • 22
  • `The sample app is a little misleading because it uses fragments and enableAutoActivityReports only works with Activities` - just a little :) – Konrad Morawski Oct 03 '14 at 09:40
  • Thanks for clearing that up. I was wondering if the app would crash if you call enableAutoActivityReports on API<14? Or is it simply a no-op? – arne.jans Dec 23 '14 at 13:23
  • Hi, I have replaced the Tracking id in the sample app with my tracking id that was already created in Google Analytics. When I run the sample app, I cannot see actions triggered or cannot even view the screen started info in the Google Analytics UI. Can you please tell me what I am doing wrong.? – Ashokchakravarthi Nagarajan Mar 09 '15 at 10:56