Android Java or Kotlin example for sending Custom Events & Parameters to Google Analytics 4

623 views Asked by At

Looking for most recent Google Analytics 4 for Android custom Events implementation / example / instructions. Specifically looking for:

  • Java or Kotlin code needed to send custom events with custom parameters
  • Additional steps in Google Analytics admin for creating custom definitions / parameters

I'm not looking for old Firebase events as this is now part of GA4 - its different now.

Google's help for this shows a video with web examples that are not applicable to Android directly.

So, a recent implementation or code sample would be very helpful.

1

There are 1 answers

1
Game Programmer On BEST ANSWER

Here is a link to Google's official documentation on sending custom events with custom parameters in Google Analytics 4 for Android:

https://developers.google.com/analytics/devguides/collection/android/v4/events

Here is an example of code for sending custom events with custom parameters in Google Analytics 4 for Android using Java:

// Get the tracker.
Tracker tracker = getDefaultTracker();

// Build and send the custom event.
tracker.send(
    new HitBuilders.EventBuilder()
        .setCategory("Video")
        .setAction("Play")
        .setLabel("Trailer")
        .setValue(1)