Firebase Analytics Filter By User ID
Asked Answered
C

4

18

The Firebase Android SDK for analytics provides a method named setUserId(String id), now i enabled firebase logging and every time i called the method setUserId(1234) i see this in the logs Setting user property (FE): _id, 1234.

My question is how come the Firebase dashboard does not let us filter by this property, there is no property not for userId and not _id, i even tried to add _id as a property in the dashboard but Firebase does not allow property names to start with an underscore.

Do i really have to stop calling that method and just do setUserProperty("userId", 1234) or am i missing something...

Communicant answered 9/2, 2017 at 12:49 Comment(0)
C
28

I have spent a few hours on this and found the answer i was looking for more or less, hopefully this might save someone else some time.

The only way to filter by Firebase's User Id property is by creating an audience, there you will be able to pick the user id property that is supplied from the setUserId(String id) method.

It is a downer though because you won't see any events for the user/user's you want from before the audience was created.

Communicant answered 9/2, 2017 at 14:5 Comment(9)
How to create an audience in firebase analytics?Gallion
Thanks! Did you find solution with it? Are you using setUserIdfor filtering or setUserProperty?Gallion
Using setUserProperty("userId", 1234) when your user logs in and using setUserProperty("userId", null) when user logs out will be a better solution. It will allow you to filter the event. Isn`t it ?Antithesis
@Antithesis why is it necessary to call setUserProperty with null?Sandbag
So that if any events are generated post user signs out then they will not be attributed that user.Antithesis
by creating audience, is it possible to filter data using USER ID ?Hoebart
@shaqirsaiyed this might be outdated since i have not worked with firebase for over a year but from what i remember back then if you create an audience you will be able to filter data by user id but you will only see data that was created after creating the audience.Communicant
@Communicant I am able to see audience for particular group of users but I am not sure if I can see user_id of those users...Hoebart
Thanks for the answer. This is so stupid that setUserId() is official api and can not really us it to filter events. This is kind of very basic use case. Firebase, is there a better way?Recitation
R
10

I was scratching my head with this issue. Initially, I felt so dumb when I could not find how to use user id for filtering in Firebase analytics dashboard that I am setting with official API setUserId(). When I try to look for answer, I realized that I am not the only one. Finally, this is how I was able to filter events based on user id.


In Android Code, I set user id using setUserId() method. When I read bigQuery has this property as user_id, I thought to give it a try by adding a new user property in Firebase Dashboard with the hope that it will fetch the reported id. New user property

And... that worked...Now I can filter new events based on user id. enter image description here

Recitation answered 5/10, 2020 at 19:43 Comment(2)
I tried it, but it says "User properties cannot be named 'user_id'" :(Muscle
I checked. Looks like Google changed something again. Why google why? Old project still have it but can not add to new project. They are making sure you never find user_id in firebase. A way to push for big-query? or hopefully they made it easier.Recitation
B
4

this is new way to filter by user ID: Step 1: Go to Firebase console -> Analytics Dashboard -> Click on 'View more in Google Analytics' at Top Right Screen

Step 2: Select Tab 'Explore' in Left Panel

Step 3: In TECHNIQUE Filter -> select 'User Explorer' then you will see the result enter image description here

Baluchistan answered 8/5, 2024 at 6:41 Comment(0)
P
1

In audience you have to select contains, exactly match or regular expression for a field.

So to filter for a user you have to add all your users to the audience, which looks cumbersome.

Isn't using setUserProperty is better? Have you faced any problems with using it ?

Parkland answered 17/8, 2017 at 13:45 Comment(1)
what's the difference between using setUserId() and setUserProperty() and how does this affect being able to search/filter for a particular user id within an audience?Sandbag

© 2022 - 2025 — McMap. All rights reserved.