Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics custom event tracking on android apps

I'm trying to get info about specific button clicks inside my app. What I've done so far (using one of the guides I've found on the web) is :

Tracker tracker = GoogleAnalytics.getInstance(this).getTracker(ID);

HashMap<String, String> hitParameters = new HashMap<String, String>();
hitParameters.put(Fields.EVENT_CATEGORY, "UI Action");
hitParameters.put(Fields.EVENT_ACTION, "Button Pressed");
hitParameters.put(Fields.EVENT_LABEL, "play");

tracker.send(hitParameters);

I'm not getting any reaction to this code at the google analytic website. Is there something wrong with the code?

Notice: * The real time analytics and overview is working great in general, except those events.

like image 896
mgR Avatar asked Mar 03 '26 12:03

mgR


1 Answers

I\ve done this the following way (using easytracker & v3 version of analytics):

EasyTracker easyTracker = EasyTracker.getInstance(this);
easyTracker.send(MapBuilder
    .createEvent(
        "UI Action", // Event category (required)
        "Button Pressed", // Event action (required)
        "play", // Event label
         null) // Event value
    .build()
 );

Also see here

Other than that, please note that events can take a while to show up on the analytics page in my experience.

like image 108
Aal Avatar answered Mar 06 '26 00:03

Aal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!