简体   繁体   中英

Events not being sent in Google Analytics (Android app)

I'm watching DebugView on the Google Analytics pages and all my ScreenViews are showing up just fine.

But my app is also sending events and they just don't show up at all.

I'm sending ScreenViews with (pseudocode):

sTracker = sAnalytics.newTracker(R.xml.global_tracker);
sTracker.send(new HitBuilders.ScreenViewBuilder().build());

And I'm sending events with:

sTracker = sAnalytics.newTracker(R.xml.global_tracker);
sTracker.send(new HitBuilders.EventBuilder()
        .setCategory("event")
        .setAction(eventName)
        .build());

I've used:

adb shell setprop debug.firebase.analytics.app <package_name>

to enable the analytics output in logcat. When I send a screenview there's loads of activity and the screenview appears in the online DebugView.

But when I send an event there's no activity at all.

Am I missing some secret config somewhere?

Thanks

===============

Partial answer: I used adb shell setprop log.tag.GAv4 DEBUG to increase the logging to logcat and it said: Discarding hit. Missing tracking id parameter: cd=org.whatever,a=,t=event,...,ea=,ec=event

So instead of contructing the Tracker with the XML, I'm constructed it with a string (a Tracker ID value). So now it sends the event but it still doesn't arrive at the DebugView, probably because I'm not using the correct Tracking ID.

Can anyone shed any light on where I can find this Tracker ID? The documentation seems out of date - it's not where it says it should be. I can't find a Tracker ID anywhere.

Thanks.

Well, the only way I found to get the Tracker ID was to delete the account - Google then emails you, including the UA-xxxxxx number and you can go and undelete the account; by adding the property/data stream ID on the end of the UA-xxxx number you can re-construct the Tracking ID (form UA-xxxxx-x). You can also delete the Property (or Data Stream, I'm not sure now) and they sometimes email you the actual full Tracking ID.

But even with the Tracking ID I couldn't get the events to show up on the server. The only way I got it working was to ignore all the documentation as send the events as follows instead:

sFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
// Add Parameters like this:
Bundle params = new Bundle();
params.putString("param_name", "param_val");
sFirebaseAnalytics.logEvent(eventName, params);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM