Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

android - How to add Firebase custom events for analytics?

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);
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...