How to set Gender User Property manually in Firebase Analytics? - firebase

Firebase collects some user properties automatically but the question is, how does Firebase know what the user's gender is?
I tried to set them programmatically but it didn't help because there's no data about genders on the Firebase Console. In other word, setting predefined user properties programmatically could not be collected by Firebase.
mFirebaseAnalytics.setUserId(Long.toString(user.id));
mFirebaseAnalytics.setUserProperty("Gender", user.sex);
mFirebaseAnalytics.setUserProperty("Age", Integer.toString(age.getYears()));
Note: I'm using free plan and I waited for +24 hours to see the result.

Firebase collects some user properties automatically but the question is, how does Firebase know what the user's gender is?
From this help article:
Demographics and interests data comes from anonymous identifiers for mobile apps (i.e., Advertising ID for Android and IDFA for iOS).
You cannot set or override the built-in user properties yourself, however if you believe you have better data for each user you can create a custom user property and set that yourself to be used separately to the built-in value.

User properties created in code need to be registered in the Firebase console to view them there. The default user properties (Age, Gender etc) however cannot be registered in the console, since they already exist.

Related

Updating user properties in Firebase takes too long

I am using firebase for my mobile Android and iOS app and I want to send push notifications based on specific user properties that I set (push notifications topics don't work for my use case).
So now when I set a user property in via the app it takes forever for that change to be propagated. For example, I do have a property club which was set to a value x. I can successfully send push notifications to those users. Now when I change the value to club = y and this change will take forever to go through. Which means that all notifications sent to club = x will still be received on those devices.
To set user properties I use the firebase_analytics plugin for flutter as follows:
FirebaseAnalytics analytics = FirebaseAnalytics();
analytics.setUserProperty(name: 'club', value: 'some value')
Since I am using the user properties to set notification settings this delay is not acceptable. Does anyone know how to make this work with firebase? Or are there any guarantees at least after which amount of time these user properties get updated?
I don't want to use other services such as OneSignal etc. but stay in the firebase ecosystem completely if possible.
Per the Analytics doc
Note: Once the property is registered, it can take several hours for data collected with the property to be included in reports. When the new data is available, the user property can be used as a report filter or audience definition.
Which is what I assume is the cause for your delay.
Topics would be the way to go, but since as you mentioned it is not viable, you could set custom claims for the user and filter it that way as mentioned here but performance might not be great since you have to retrieve all your users first.
You could create a club collection in Firestore and for each clubName document have a toNotify subcollection containing the userIds as document name. In this context users would remove themselves from the previous clubName and create a new doc in the newClubName.
Keep in mind this has the potential of causing quite a lot of read operation depending on the frequency you send notifications and the size of the your userbase.

Programmatically create Audience in Firebase

Is there the possibility to create an Audience in Firebase programmatically?
My users have a custom property with a value. I want to create an audience with user with a certain set of values (each value different for each user).
Via console, I could add a rule for each and every value, so I would like to do this programmatically, but I can't find the relevant documentation.
Is this possible? Don't know whether I should look more into firebase or more into google analytics...
Sorry, there's no API for manipulating the Firebase console with respect to Analytics.
However, feel free to file a feature request with your use case.

Client ID and/or User ID - which to use?

Background of my specific environment: I am trying to set up GA to track the user journeys around an iOS native app written in React Native. The app is in-house only and all users consent to being tracked in this way.
As I understand it, the measurement protocol allows either Client ID (cid) or User ID (uid). In the docs, both are optional, but at least one is required. Makes sense so far. Client ID is an anonymous UUIDv4 that tracks a browser or device, but not necessarily a user. User ID on the other hand is some uniquely-identifying value for a user, but may cross devices/browsers.
Initially I wrote my application using cid (as I hadn't yet read the docs on uid). Every time a user logged in the user's uuid would be stored and sent as the cid parameter. I also used session control sc. This worked - I saw sessions coming in, the User Explorer showed me the individual user uuids and sessions, etc. But upon rereading the docs, this seemed like an incorrect use of cid. It seems like cid is meant to be consistent and not something that changes as you log in and out.
As people on my app can log in and out (and possibly will - staff members may well share devices), using a long-lasting cid that is specific to the device won't allow me to track the habits of individual users and changing it per login-session, as mentioned above, feels wrong.
So I switched out cid for uid. The docs say both are optional and one is only required if the other is not used, so I figured I could just use uid and use the user's uuid in that field and it's otherwise act the same.
However, when doing it this way no hits seems to be registered at all - in "real time data" as well as the User Explorer.
Am I doing something wrong or is this by design? (If by design, are the docs wrong to say cid and uid are both optional or am I reading it incorrectly?)
Either way, best-practices-wise, do I:
Just go back to using an ephemeral cid that only changes when people log in and out. Individual sessions in the app don't change the cid but I do use sc to explicitly start and end sessions by navigation inference (click 'home' = sc=end, navigate from 'home', sc=start).
Use uid as I am trying to (i.e. switching out the current cid for uid), but also include a random cid that never changes (regardless of session lifetime, logging in and out, etc.).
Something else?
I have seen this question and its answer but it does not really answer my actual question regarding how cid and uid should actually be used, and if my issue is me or the way that GA works.
Oki so client-id is randomly generated value and must be sent with all hits.
In a non-User-ID-enabled view, Client-ID is used to calculate unique users. In a User-ID-enabled view, User-ID is used to calculate unique users
In reference to your app, you can send the unique Device id value in place of random value for client-id. This will resolve all your problems and ensure that the client id is sent with all the hits, otherwise it wont get registered in GA

Age and Interests fields isn't exported to BigQuery

How can I query some of the automatically collected user
properties from the Firebase database?
I'm looking for attributes that are not available on BigQuery tables named as app_events. For instance, I am looking for user attributes
age, gender, and interests as listed here.
Thanks in advance.
The properties you are looking for are available on the Firebase console of your project. Click "Analytics" below the Firebase logo, and then select the appropriate tab, e.g. "Audiences" to see the data you are requesting. As far as I know, they are not accessible from within your application.

Query Google Analytics by User ID

Is there a way to query results using the Core Reporting API (v3) and filtering those results by the User ID assuming that it is being sent to Google Analytics properly?
I've googled this question a lot and read a whole bunch of articles but I did not find one place that does that. Moreover, the fact that I cannot see the User ID anywhere in the reporting interface makes me doubt that this is even possible. I'm guessing I will have to dome something similar to what is recommended here in order to do it?
UPDATE
Apparently, the purpose of my question is not very clear as highlighted by Eike's comment below. What I want to do is generate a report for a specific user with a specific Id using the client API and then combine those results with information I have about this user in my system's database to do something as per my business requirements.
The best place to turn to for such questions is the Dimensions and Metrics Reference. If the dimension you're looking for is not there then you cannot query it or use it in a filter.
The list is really well maintained, so it's not very likely there are as-of-yet undocumented dimensions you could use.
User id is not there.
Well there is a way now.
The docs says the following steps
Set up User-ID in your account
Agree to the User-ID Policy
Read the User-ID Policy. Under I agree to the User-ID Policy, set the switch to ON. Agreeing to the policy enables the feature in your account.
Click Next Step.
2. Set up User-ID in your tracking code
After you enable User-ID by agreeing to the policy, you must implement User-ID in your tracking code.
To employ User-ID, you must be able to generate your own unique IDs, assign IDs to new users and consistently reassign the same IDs to returning users, and include these IDs in the data you send to Analytics.
In this step, you can see the line of code that you have to add to your Analytics tracking code:
ga('set', 'userId', {{USER_ID}}); // Set the user ID using signed-in
user_id.
3. Create a User-ID reporting view
User-ID data can appear only in a dedicated User-ID view.
Click Create.
Enter a Reporting View Name.
You might want to include the term "User ID" in the name to help you remember that this is a special User-ID view.
Select a Reporting Time Zone.
Under Show User-ID Reports, set the switch to ON.
Click Create.
Related resources
https://support.google.com/analytics/answer/3123666?hl=en

Resources