User properties are attributes you define to describe segments of your user base, such as language preference or geographic location.
Analytics automatically logs some user properties; you don't need to add any code to enable them. If you need to collect additional data, you can set up to 25 different Analytics User Properties per project. Note that user property names are case-sensitive and that setting two user properties whose names differ only in case results in two distinct user properties being logged.
Before you begin
If this is your first time adding Analytics to your app, complete the following procedures:
Connect your app in the Firebase console
Add Analytics to your app
If you haven't already added Analytics to your app, in your
Activity, initialize the
private FirebaseAnalytics mFirebaseAnalytics;
// ...// Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Set user properties
You can set Analytics User Properties to describe the users of your app. You can analyze behaviors of various user segments by applying these properties as filters to your reports.
Set a user property as follows:
Add code to set an Analytics User Property with the
The following example
adds a hypothetical favorite food property, which assigns the value in
mFavoriteFood to the active user:
You can access this data as follows:
- In the Firebase console, open your project.
- Select Analytics from the menu to view the Analytics reporting dashboard.
The User Properties tab shows a list of user properties that you have defined for your app. You can use these properties as a filter on many of the reports available in Google Analytics for Firebase. Read more about the Analytics reporting dashboard in the Firebase Help Center.