Pratzz Pratzz - 4 months ago 44
Android Question

How to create a custom user property for firebase?

The help section on the firebase console says that


Firebase app can have up to 25 uniquely named user properties (case-sensitive). You should use properties for non-variable attributes, such as “handedness=right”, “spender=true”.


In the firebase documentation https://firebase.google.com/docs/analytics/android/properties a property is said be to set this way


mFirebaseAnalytics.setUserProperty("favorite_food", mFavoriteFood);


Does this mean that for every user property named k and having a value v, we need to create a user property in the console as "k=v" and set it in the code by setUserProperty(k,v)? So, for a user property called "favorite_food" having the possible values as "pasta" and "pizza", one needs to create two new user properties in the console as "favorite_food=pasta" and "favorite_food=pizza" and set it by, say, setUserProperty("favorite_food","pasta")?

Answer

For every User Property named k, you need to register an entry in the "User Properties" tab in Firebase Analytics. For every user with User Property value k=v, you need to call setUserProperty(k,v).

After calling setUserProperty(k,v) (and after logging some events), you will be able to filter your Analytics reports by applying a User Property filter for k=v (favorite_food=pizza) .