How to generate specific user statistics from Firebase? - firebase-realtime-database

I'm using Firebase Auth and Firebase RTDB for a B2B App. At this time I would like to establish a mechanism to detect if the App has not been used in the last 24 hours and thus activate churn prevention schemes per user/company.
I have considered two alternatives:
Make a record in Firebase RTDB every time a person enters the APP, however I see the following drawbacks:
I must generate a new App update
I must modify the structure of the database with new records
I must establish new security rules
Use Firebase Analytics. I find this approach interesting, but I'm not sure if this type of behavior/event can be identified at the specific user level.
Is it possible to generate usage statistics for specific users in Firebase Analytics?
Can I have specific segments in Firebase analytics with specific UIDs grouped?
Have you tried any other approach to get this type of usage statistics?

Related

Tracking active users on Firebase

Apologies if this question has already been asked but I have no been able to find it. I'm trying to figure out if there is a way to track how often a user opens my app if they're already logged in. Firebase only shows the last time they're signing in, but not if they're already signed in so I don't know when they've actually been opening my app last.
There is no presence tracking built into Cloud Firestore. It just doesn't match well to the protocol that Firestore uses to communicate between client and server.
The simplest way to get this working is to use the Realtime Database, and potentially synchronize the information to Cloud Firestore from there. For a walkthrough of this (quite involved) scenario have a look at the Firestore documentation on building a presence system.

Firebase to send backend emails or format data for review

Just a quick question if anyone has any insight / knows any good tutorials or guides. An ios app I am making consists of user-generated content and because of App Store rules, it must provide the user with the ability to report offensive/illicit content.
When the user reports something, my app creates a node with all the information of the report on the Firebase Database. Now, I could just review by using the Firebase console, but this would be very tedious so I'd like to implement some code that, whenever a node is created under "Reports" gets all the data from the database and storage and sends it as an email to a given account or stores it in an easily reviewable format.
Does anyone know how to implement this sort of backend code?
Thank you
This sort of situation is ideally suited for Cloud Function for Firebase, which allows you to run small snippets of JavaScript code in response to events such as a node being written to the database.
I recommend that you have a look at the Cloud Functions for Firebase documentation, specifically at the list of sample use-cases and even more specifically at the sample of sending a confirmation email when a user signs up for a newsletter.

Using Firebase with multiple users in an iOS app

A number of iOS apps I develop are used in scenarios where the Organisation has a number of Drivers and the iPhone is shared between them. Each Driver has his own app credentials, logs in to the app, and is presented with his own set of data. The Firebase data is persisted as he is offline most of the day and I use keepSynced(true) to ensure data is up-to-date.
The problem I'm having is that once a user logs out with the Firebase method FIRAuth.auth()!.signOut() then when a different user logs in, he sees the previous users' data. I'm guessing that because the data is persisted it is not cleared from the cache. However, I am retrieving the data by the user id so this doesn't quite explain it.
What is the best pattern to permit multiple users to use the same iOS app with Firebase ?
Try creating multiple instances of FIRApp, each with a different name, using the +configureWithName:options: method. Then use the different apps in FIRAuth +authWithApp and elsewhere as needed.
I haven't actually done this and am too new to Firebase to say it's the best pattern, but it seems like it should work.
One thing to note from the docs is that, "On Android and iOS, Analytics are only logged for the default app." One solution might to keep the __FIRAPP_DEFAULT app, and then make a named app for each user type.

Can I track session duration of a specific user-id via Google Analytics?

I have an iOS app with Google Analytics to track engagement/retention, and I have been trying to set up a way to track the session durations of specific users. I followed all of the steps to send the User-ID value when a user logs into a session (using &uid), and I have also created a User-ID enabled reporting view. However, I have no idea how to sift through the bulk session data to pick out the behavior of an individual user. Thanks for your time and help, this is really important to my company.
User ID - iOS SDK
The User ID feature enables the measurement of user activities that
span across devices in Google Analytics, such as attributing an
interaction with a marketing campaign on one mobile device to a
conversion that occurs on another mobile device or in the browser.
When User IDs are sent with Google Analytics hits using the userId
field, your reports will reflect a more accurate count of unique users
and offer new cross-device reporting options.
Userid is used internally by Google analytics to give you more actuate user data in your reports, there for your reports already have it included.
If you are trying to find the value itself so that you can track a user though their use of your application you cant. Google Analytics doesn't allow you to track individual users that would violate their privacy. You could add this value as a custom dimension and track them that way as long as its a non identifiable userid you are using, something that cant be tracked back to a specific user.

Google Analytics for iOS 1-time (per user) event tracking

I am using Google Analytics iOS SDK (version 2 but will upgrade if it solves problem). How can I track what percentage of my app users have pressed a certain button at least once? I set up a lot of event tracking, thinking this would do it, but the reports are in terms of sessions not users. E.g., it will show what percentage of sessions included an event, so a single user may be counted multiple times. I defined a custom dimension variable that is unique for each app install, but I don't see how to use that as aggregation unit.
All I can think of is to define my own "one time events" by keeping my own database on the device and only pass to Google Analytics the first time it occurs. Is there no better way?
Google Analytics now offers User segment. You could create a user segment, and use the particular event you're interested in as a condition.
In the context of app measurement, a User is defined as a unique Client ID, which is the random ID generated by the GA SDK when the application first runs. It remains stable for as long as an app is installed.
More details here: http://analytics.blogspot.com/2013/07/re-imagining-segmentation-in-analytics.html

Resources