How to add Firebase custom events for analytics?

AndroidFirebaseFirebase AnalyticsFirebase Console

Android Problem Overview


I've seen some questions and answers about custom events for firebase analytics, but i just wanted to ask you a straight question so you can give me a straight answer :)

So, this is my method for logging:

@Override
public void logFeatureSelectedEvent(String categoryName, String actionName, String labelName) {
    Bundle bundle = new Bundle();
    bundle.putString(EventTrackingKeys.EventTypes.CATEGORY, categoryName);
    bundle.putString(EventTrackingKeys.EventTypes.ACTION, actionName);
    bundle.putString(EventTrackingKeys.EventTypes.LABEL, labelName);
    mFirebaseAnalytics.logEvent(EventTrackingKeys.EventAnalyticTypes.FEATURE_SELECTED_EVENT, bundle);
}

with custom event/key names:

String CATEGORY = "category";
String ACTION = "action";
String LABEL = "label";
String FEATURE_SELECTED_EVENT = "feature_selected_event";

So, in my firebase console I only get event name "feature_selected_event", without custom parameter names.. I've seen some answers that i should call setUserProperty() method and register that user property in the User Properties tab of Firebase Analytics. Is this the right way to implement that method? :

   @Override
public void logFeatureSelectedEvent(String categoryName, String actionName, long value) {
    Bundle bundle = new Bundle();
    bundle.putString(EventTrackingKeys.EventTypes.CATEGORY, categoryName);
    bundle.putString(EventTrackingKeys.EventTypes.ACTION, actionName);
    bundle.putLong(EventTrackingKeys.EventTypes.VALUE, value);
    mFirebaseAnalytics.setUserProperty(EventTrackingKeys.EventTypes.CATEGORY, categoryName);
    mFirebaseAnalytics.setUserProperty(EventTrackingKeys.EventTypes.ACTION, actionName);
    mFirebaseAnalytics.setUserProperty(EventTrackingKeys.EventTypes.VALUE, value);
    mFirebaseAnalytics.logEvent(EventTrackingKeys.EventAnalyticTypes.FEATURE_SELECTED_EVENT, bundle);
}

Android Solutions


Solution 1 - Android

You can see it in console without any hacks, but it is pretty hidden there.

Go to Firebase Analytics -> Stream View -> Select Events -> Top events -> select_content -> there you go

My code:

Bundle params = new Bundle();
params.putString("invalid_url", urlPart);
mFirebaseAnalytics.logEvent("eventInvalidUrl", params);

Firebase Analytics Stream View

Solution 2 - Android

The custom parameters will not be shown. Only suggested events with suggested parameters are presented in dashboard.

To see the custom parameters, you have to link your project to Big Query (it's not free).

Also Firebase will not show information if the number of user is less than 10.

Solution 3 - Android

If you are still looking for answer, You need to add custom parameters into the event manually once in the dashboard Like this https://support.google.com/firebase/answer/7397304?hl=en&ref_topic=6317489 Actually there is no need to link BigQuery for this. But it will take several hours to show up custom parameter once you navigate inside the event.

Solution 4 - Android

In Firebase, As i know we have to log the events in < Key,value > pair and then need to log.

Like this :

bundle.putString("yourKey","yourValue");

For Example, I have put the Custom event in MyApp to get the AppOpen time as below.

    Bundle params = new Bundle();
    params.putString("open_time", TimeStampUtil.getTimeStamp(System.currentTimeMillis()));
    mFirebaseAnalytics.logEvent("app_open_time", params);

so, in above example i have create a custom event with name app_open_time and put the value with key as open_time.

Try in this way and for more info refer this : https://firebase.google.com/docs/analytics/android/events

Solution 5 - Android

Not only do you need to do what Muhammad Riyaz says, you also need to get your user count up above the "threshold". In my case, installing my app on a dozen simulator versions pushed my user count to 12, and voila, suddenly I have custom event parameter data in my Firebase dashboard.

Solution 6 - Android

Similar to @Josef Vancura answer, but in Kotlin:

val params = Bundle()
params.putString("invalid_url", urlPart)
mFirebaseAnalytics.logEvent("eventInvalidUrl", params)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoeView Question on Stackoverflow
Solution 1 - AndroidJosef VancuraView Answer on Stackoverflow
Solution 2 - AndroidTOPView Answer on Stackoverflow
Solution 3 - AndroidMuhammad RiyazView Answer on Stackoverflow
Solution 4 - AndroidUttam PanchasaraView Answer on Stackoverflow
Solution 5 - AndroidsaswanbView Answer on Stackoverflow
Solution 6 - AndroidJerry ChongView Answer on Stackoverflow