Create and Segment Audiences on Firebase (original) (raw)

Last Updated : 23 Jul, 2025

**Audience segmentation is an important strategy for **app developers to understand and engage with their users effectively. By dividing users into distinct groups based on **behavior, **demographics, or other **attributes developers can customize marketing campaigns, analyze user behavior, and improve user retention.

Here, We will learn about **Create and Segment Audiences on Firebase in detail.

What is Audience Segmentation in Firebase?

An **Audience in Firebase is a group of users who share similar attributes or behaviors. **Audience segmentation involves dividing our users into distinct groups based on specific criteria such as behavior, demographics, or other attributes. By segmenting your users into different audiences, you can tailor your marketing efforts, in-app messages, and other interactions to better suit their preferences and actions.

This allows you to:

Setting Up Firebase

Before diving into audience segmentation, ensure you have a Firebase project set up and your app integrated with Firebase. Follow these steps if you haven't done so:

For detailed setup instructions, refer to the Firebase documentation.

Creating Audiences on Firebase

Step 1: Define Your Audience

Audiences in Firebase are defined based on user properties, events, or a combination of both. Common criteria include:

Step 2: Create Audience in Firebase Console

Creating an Audience on Firebase Examples

Let us look at some of the examples of creating an Audience in Firebase:

Example 1:

Let's create an audience of active users who have opened the app at least 10 times in the last 30 days.

Example 2: Creating an Audience Based on User Property

Let's create an audience of users who have a premium subscription.

Segmenting Audiences on Firebase

Let us now learn segmenting Audiences on Firebase.

Step 1: Use User Properties

User properties are attributes we define to describe segments of our user base. Examples include "**subscription_type" or "**user_level."

**Setting User Properties

Set user properties in our app using the Firebase SDK.

**import com.google.firebase.analytics.FirebaseAnalytics;

// Initialize Firebase Analytics
**FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(**this);

// Set user property
mFirebaseAnalytics.setUserProperty(****"subscription_type", "premium"**);

**import Firebase

// Initialize Firebase Analytics
**let analytics = **Analytics.**self

// Set user property
analytics.setUserProperty("**premium", forName: "**subscription_type")

**import { getAnalytics, setUserProperties } from ****"firebase/analytics";**

**const analytics = **getAnalytics();

// Set user property
**setUserProperties(analytics, { **subscription_type: '**premium' });

Step 2: Track Events

Events are actions users take in our app, such as "**app_open" or "**purchase." Use these events to segment our audience.

**Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_ID, "**id123");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, "**item_name");
params.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "**image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, params);

analytics.logEvent(**AnalyticsEventSelectContent, parameters: [
AnalyticsParameterItemID: "**id123" as **NSObject,
AnalyticsParameterItemName: "**item_name" as **NSObject,
AnalyticsParameterContentType: "**image" as **NSObject
])

**import { logEvent } from "**firebase/**analytics";

// Log event
logEvent(analytics, '**select_content', {
item_id: '**id123',
item_name: '**item_name',
content_type: '**image'
});

Analyzing Audience Data on Firebase

Audience Reports

Firebase provides detailed reports for each audience you create.

**Outputs

Advanced Audience Segmentation

Here are some of the Advanced Audience Segmentation on Firebase:

1. Using Custom User Properties

Custom user properties allow us to segment users based on attributes specific to your app.

**Example: Setting a Custom User Property

Let's set a custom user property "**user_level" to segment users based on their experience level.

mFirebaseAnalytics.setUserProperty("**user_level", "**beginner");

analytics.setUserProperty("**beginner", forName: "**user_level")

**setUserProperties(analytics, { user_level: '**beginner' });

2. Combining Multiple Conditions

Create more sophisticated audiences by combining multiple conditions.

Example: Active Premium Users

3. Using Predictions in Firebase

Firebase Predictions use machine learning to predict user behavior, allowing for more advanced segmentation. For instance, you can create audiences based on predicted churn or high spenders.

Example: Creating a Predicted Churn Audience

Custom event parameters allow for even more detailed segmentation. You can track specific actions within events, like the amount spent in a purchase event.

**Bundle **params = **new Bundle();
params.putString(FirebaseAnalytics.Param.CURRENCY, "**USD");
params.putDouble(FirebaseAnalytics.Param.VALUE, **9.99);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.PURCHASE, params);

analytics.logEvent(**AnalyticsEventPurchase, parameters: [
AnalyticsParameterCurrency: "**USD" as **NSObject,
AnalyticsParameterValue: **9.99 as **NSObject
])

**logEvent(analytics, '**purchase', {
**currency: '**USD',
**value: **9.99
});

Best Practices for Audience Segmentation

  1. **Define Clear Objectives: Understand what you want to achieve with audience segmentation.
  2. **Use Descriptive Names: Give your audiences clear and descriptive names.
  3. **Combine Multiple Criteria: Create more targeted segments by combining multiple conditions.
  4. **Regularly Review Audiences: Monitor your audiences regularly to ensure they are still relevant.
  5. **Leverage Audience Insights: Use insights from audience reports to optimize your app and marketing strategies.
  6. **Utilize Machine Learning: Implement Firebase Predictions for dynamic and predictive segmentation.
  7. **Ensure Data Privacy: Always comply with data protection regulations and ensure user data is handled securely.

Conclusion

Audience segmentation is a valuable strategy for app developers to personalize user experiences, optimize marketing efforts, and improve overall app performance. By setting up Firebase for audience segmentation and creating targeted audiences based on user properties and events, developers can gain insights into user behavior and make data-driven decisions to enhance their app's success.