androidparametersgoogle-analyticscustom-events

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


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

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.


Solution

  • 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)