Getting Started with Firebase Analytics on iOS: User Properties – Firecasts

Getting Started with Firebase Analytics on iOS: User Properties – Firecasts


[MUSIC PLAYING] TODD KERPELMAN:
So as we discussed in our last video, which
you should probably watch if you haven’t
yet, Firebase Analytics is all about recording events
that happen within your app and sending them down
to the Firebase console so that you can start to get
some information about them. And while seeing this
data in aggregate is nice, sometimes you want to break this
down into more specific user segments. I mean, sure it’s
nice to see people are visiting your in-app store,
but who are these people? Are they tablet owners? New users? Canadians? Knowing who these people
are can make it easy for you to optimize your
app to get better results. Now by default,
Firebase Analytics provides a number of
segments for you for free. You can filter any
particular event by device, type, or country. And if you have
ad-support enabled, things like gender
and age as well. But very often your app will
have its own specific user properties that you’ll also
want to use to filter your data. An exercise app
for instance, might want to see how users with
different fitness goals behave. Do your yoga enthusiasts
subscribe to your newsletter more often than your
runners, for example? That’s something you
can start to find out if you filter your data
against custom user properties. So custom user properties
are simply key value pairs that you set in the Client. Every time Firebase
Analytics sends down a batch of events
to its servers, it also sends down
any user properties that have been recorded
for that particular user. Both for that session
and any time in the past. These things will persist
for the lifetime of your app. Now Firebase will
take those events and make sure they
get associated with all of your user properties
so you can filter these events later on by those properties. Now this has two implications
for you as a developer. First, user properties
are not retroactive. Once you set a user property
for a particular user, any and all future
events will be associated with that property. But don’t expect that
their previous events will be magically updated. Those remain unchanged. Second, don’t think you can
change your user property every 30 seconds, and
expect that every 30 seconds worth of data will be
associated with that updated user property. A user property is something
you should change more in the magnitude
of days or weeks. If you’re trying to change
it more frequently than that, you might want to
look at other options instead, like custom
event parameters. Now in general, the process for
creating a new user property is pretty straightforward. On the Client, you’re going
to set a key value pair representing the user property. And then in the
Firebase console, you’re going to add
the user property to the list of all
user properties that you filter your data by. And that’s about it. So with that in mind, let’s set
some user properties for real. Remember this app
from the last video? The one where we were recording
button presses and slider adjustments? Well, our marketing
team has this theory that cat people are
more likely to adjust the slider than dog people. But they want to back
up that claim with data. So let’s see how. First off, you can see that
from my View Did Appear, I’m calling a method that
asks my users if they’re a dog or cat person. This should be pretty
straightforward if you’ve ever used a
UI alert controller. Next, we’ll use that information
to store user property. In my cat person
handler, I’m going to set a property by
typing fur analytics dot set user properties string
cat person for name dog or cat person. Note that you set the value
first and then the key name. I always get that mixed up when
I’m first setting these things. Oh, by the way, we have
no official recommendation as to whether or not you go
with camel case or underscores. Just try and stay consistent or
you’ll drive yourself bonkers. Anyway, and I’ll do the same
thing in my dog person handler method. Fur analytics Set User
properties string dog person. And then we’ll paste that in. My code is set. But I also have to make sure
I register this user property on the Firebase console. Otherwise they won’t
be able to use it. So we’ll go to the Firebase
console, select analytics for my project, and then
click on User Properties here. And I’ll click Create Your First
User Property to create one. And this is the one place you
need to be extra super careful. You can use up to 25
custom user properties, but right now you can’t
delete or rename these things once you’ve entered them. So for starters,
don’t fill this up with a lot of test cases or
experimental user properties that you arent’
going to need later. And for another, do make
sure you get the name right, and don’t misspell
it or anything. In fact, I like to copy
and paste the property name directly from my record,
just to make sure. And that’s what I’m doing here. So I’m going to add
a little description. And I’m going to double check
to make sure this looks good. And it does. So we’ll create it. Now I’ll go back to
my app and run it. I’ll say that I’m a cat person. And you can see here
in the XCode console that is now specified that
my user property is now cat person. Now I’m going to
go ahead and use the controls for a little bit. And OK, we’ll go
into the background. And you can see here in
the XCode console that it’s sending down not only the events
that are recorded, but also the dog or cat person user
property that Firebase Analytics will associate
with these events. Now obviously in a
real app I’d probably want to record this information
once and not ask again. But for testing and
demonstration purposes, it’s kind of nice to get
this dialog every time. So I’m going to
build and run again. I’ll say I’m a dog
person this time around, perform a few other actions, and
send down those events as well. Now I’m going to
wait a few hours and check out my results
in the Firebase console. So it’s a day later, and let’s
take a look at these events. I’m here in the
Firebase console, and I’ll click on Events. And then select my
Adjust Slider Event. I’ll switch the dropdown here
to Yesterday to just focus on yesterday’s events. And here I can see the total
events I have for yesterday. Then I’ll click on Add
Filter, User Property, cat or dog person. And then I’ll type
cat person here. And ah-ha. This is interesting. I have zero events. Somehow none of my
events are being attributed to their
user properties, which is kind of weird. So I asked around. And it seems like perhaps
my simple test case wasn’t quite enough to get
Firebase Analytics to start using these user
properties in its reports. There’s a minimum threshold
I need to meet here that I haven’t quite met yet. So I’m going to run
this a few more times and submit some more events for
both my dog and my cat people. And that should
hopefully fix things. So now I’m back to the
Firebase console here. And we’ll go and select
Events and Adjust Slider. And I’m just again, going
to focus on our events for yesterday. And now I’ll filter this by User
Property, dog or cat person. And oh, this is promising. You can see these values are
now available in the drop down list. So now I can filter
this by cat person and then compare
these values here with what I get when I
filter by dog person, which does look like much fewer. But be careful here. Don’t get fooled by
these absolute numbers. If I had five times more
dog people out there than cat people, I might
see more total Adjust Slider events for my dog people. I really should be looking
at these count per user stats to see which population actually
prefers adjusting the slider more. But looking at what
I do have here, it looks like our marketing
folks are right. Cat people really do like
adjusting sliders more than dog people. Maybe that little circle
looks like a laser pointer to him or something? Anyway, I hope that gives
you enough background to get started adding user
properties to your own apps. Start thinking about what
segments of your audience you’re curious about because
that can start determining important factors like where you
want to prioritize development, or where you want to spend
your marketing dollars. In the meantime, feel free to
check out our documentation, subscribe to the
Firebase channel, and I’ll see you soon on the
next episode of Firecasts. The magical red dot! It’s back! I’m going to get you! I’m going to get you! Back! Back! Back! Back! Back Back! Back! Come back! Back here! Please wait!

7 thoughts on “Getting Started with Firebase Analytics on iOS: User Properties – Firecasts

  1. I also added some User Properties in Analytics. And now I want to delete it but it only has an edit button. There doesn't seem to be a way to delete them in the UI. How can I delete it?

Leave a Reply

Your email address will not be published. Required fields are marked *