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?
To set up a view: Sign in to Google Analytics.. Click Admin, and navigate to the account and property to which you want to add the view. In the VIEW column, click the menu, then click +Create View.
Events in Google Analytics 4 This means that when you create a new GA4 property and data stream, basic user interactions such as outbound link clicks, scrolls, file downloads, video engagement, and site search are automatically tracked.
Google Analytics tracks screen transitions and attaches information about the current screen to events, enabling you to track metrics such as user engagement or user behavior per screen. Much of this data collection happens automatically, but you can also manually log screenviews.
Get the project If this is your first time using a Google services sample, check out the google-services repository. Open Android Studio. Select File > Open, browse to where you cloned the google-services repository, and open google-services/android/analytics .
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With