User Segmentation 1: Defining User Segments with Firebase Analytics
Welcome to this new mini-course, User Segmentation! I’ll be covering the power of splitting users into segments to leverage features like A/B Testing, targeted Cloud Messaging, and the like.
This introduction is the only one you need to see before looking at any of the other parts of this mini-course. Once you know how to define user segments, you’ll be able to get through all the other parts of the course in any order with no problem at all.
As some sort of introduction, we’ll start by defining the user segments themselves using something called user properties. It’s quick and easy so this won’t be taking long at all!
What is a User Property?
User Properties are attributes you can set for different users that allow you to split them into segments. This can be anything you define, such as eye colour, gender, locale, etc.
Users with common user properties will be put together in a segment. You’ll be able to see these segments of your users in the Firebase Console and target them for things like Cloud Messaging or A/B Testing.
As with anything else to do with Firebase, you need to have Firebase connected to your app and of course, have the Firebase Core dependency added, as that includes Analytics.
Get an instance of Firebase Analytics
Before you can create user properties, you first need to get an instance of FirebaseAnalytics .
FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Create the User Property
There are 2 steps to this.
- Add the property in Analytics > User Properties section of the Firebase Console .
- Set the user’s property in your code with this line
This example is quite obviously setting the "eye_colour"property for the user.
Note that it may take several hours when a user property is set for it to appear on the console, but that’s it for setting the user property!
Defining Audiences in the Firebase Console
You can already target specific groups of your users with user properties, but you can optimise this further by defining audiences in the Firebase Console, in the Audiences menu under the Analytics header of the side navigation.
What you can audiences is you can perform logic operations with different user properties. This means you can filter out audiences even further (A and B) or create a broader group of audiences (A or B), and thus have more flexibility in targeting users for messages, testing, or server-side updates.
Safety and Security
Make sure to never store personally identifiable information, such as names, or email addresses, even in hashed form. You want to collect information only to deliver a better user experience, not to pose any danger.
There’s definitely a lot of ways you can leverage user segments with Firebase’s different tools and services.
As I said earlier, once you understand how to define user segments, feel free to jump straight to any other part of the course.