This tutorial aims to guide you on how to use user properties to segment data in Firebase Analytics. User properties are attributes you define to describe segments of your user base, such as language preference or geographic location. Firebase Analytics can use user properties to create more defined audiences for targeting and to analyze user behavior in more detail.
Learning Outcomes
By the end of this tutorial, you should be able to:
- Understand user properties in Firebase Analytics.
- Define and assign user properties.
- Use user properties for segmentation and analysis.
Prerequisites
- Basic knowledge of Firebase Analytics.
- Access to a Firebase project.
User properties are key-value pairs that you define for users based on their behaviors, preferences, and in-app activities. Here's how to use them:
Defining User Properties
Assigning User Properties
Set user properties in your app code using the setUserProperty
method. Here's an example:
FirebaseAnalytics.getInstance(this).setUserProperty("favorite_food", "Pizza");
Using User Properties for Segmentation
To use user properties for segmentation, first, you need to register them in the Firebase console. Then create an audience using these properties in the Audiences tab.
Example 1 - Setting User Properties
Here's an example of how to set a user property named favorite_genre
:
// Get Firebase instance
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
// Set user property
firebaseAnalytics.setUserProperty("favorite_genre", "Action");
Example 2 - Using User Properties for Segmentation
To create an audience of users who love the "Action" genre, go to the Firebase console, select Audiences > New Audience > Create a condition with "User Property" > "favorite_genre" equals "Action".
In this tutorial, you learned about user properties in Firebase Analytics, how to define and assign them, and how to use them for segmentation and analysis.
For further learning, consider exploring other Firebase Analytics features such as events or conversion tracking.
Additional resources:
- Firebase Analytics Documentation
- User Properties in Firebase
Exercise 1
Define a user property called user_level
to track the level of users in a game. Set different levels for different users.
Exercise 2
Create an audience for 'Advanced' users who are above level 10.
Solutions
Exercise 1
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
firebaseAnalytics.setUserProperty("user_level", "10");
Exercise 2
In Firebase console, select Audiences > New Audience > Create a condition with "User Property" > "user_level" greater than "10".
Remember, practice makes perfect. The more you use user properties and other Firebase features, the more comfortable you'll become with them.