Using User Properties to Segment Data

Tutorial 3 of 5

1. Introduction

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.

2. Step-by-Step Guide

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

  1. Visit the Firebase console, select your project, and navigate to the Analytics dashboard.
  2. Click on 'User Properties' on the menu.
  3. Click on 'New User Property' and provide a name and description for the property.

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.

3. Code Examples

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".

4. Summary

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

5. Practice Exercises

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.