Flutter log event with google analytics - android

I have set up Google Analytics with in my flutter app. It all seems to be working as standard, with data coming through and being displayed on the analytics console screen, showing users, events count that sort of thing.
I see the default events are: user_engagement, screen_view, session_start, first_open, app_remove, app_clear_data.
These are all having event count data coming through fine. I want to set up my own custom event within the flutter app. I have tried this...
_sendAnalyticsEvent() async {
FirebaseAnalytics analytics = FirebaseAnalytics();
await analytics.logEvent(
name: "save_plant",
parameters: <String, dynamic>{
'plant_name': currentPlant.name,
'plant_species': currentPlant.species,
'plant_group': currentPlant.group,
'new_plant': widget.newPlant
},
);
}
... but nothing seems to be coming through on the events. Am I missing something here with doing custom events with a flutter app? I have the google-services.json file correctly in the android app directory.

When You log an event with FirebaseAnalytics, it takes up to 24 hours to get it available in the Events dashboard.
If You want to test "real time" logging, You should try the Debug View (link).
After You set it up for a specific device (there are two easy steps, check it out here), You will see each event only a few seconds after You log it from Your app, in the DebugView section.

Update to 5.0.11, should resolve the issue
firebase_analytics: ^5.0.11

Related

Firebase Crashlytics - setting User ID is not working?

A useful feature from Crashlytics by Firebase is to set a userID for a session, to later look up that particular user's crash events.
It doesn't seem to be working in my Android app however. I am debugging with my device. Here is the DebugView of my device:
Where the user_id is properly set via setUserID on the Firebase Analytics object.
I then triggered a crash. But...
It can't find my userID? (I can find the crash I triggered though.)
I don't even know what else to try, according to DebugView the userID was properly set?
Well, it was as simple as:
FirebaseAnalytics.getInstance(this).setUserId(uuid); // wrong
Crashlytics.setUserIdentifier(uuid); // correct
Was overlooking "FirebaseCrashlytics" vs "FirebaseAnalytics" https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android
After getting first crash on installed application, you can search with the user id in Firebase Crashlytics
FirebaseCrashlytics.getInstance().setUserId(uuid);
Add FirebaseCrashlytics.getInstance().setUserId(uuid); in all screens (activities). If you add only in login screen then userid will not share to crashlytics, when app is crashed after reopening. Since we will ask user to login only once.
In Sep 2021 using -
com.google.firebase:firebase-bom - version 28.4.0
com.google.firebase:firebase-analytics-ktx - version 19.0.1
com.google.firebase:firebase-crashlytics-ktx - version 18.2.1
I resolved this with : FirebaseCrashlytics.getInstance().setUserId();

Unity GAv4 Plugin - LogScreen not visible, LogEvent is visible

I am adding Google Analytics tracking to my Unity game (opted in for GA instead of Firebase). I'm using GA v4, just downloaded this morning from Google, and Unity version 2018.3.14f1.
I've imported GAv4 package, have setup property ID (for Android, iOS and Others) in prefab, added prefab to hierarchy and I'm able to start session and send event using LogEvent method. These are visible in GA backoffice, I can see my device in real-time, device location and events it's firing.
However, problem is that it does not show LogScreen in the backoffice.
Here is the line that calls LogScreen:
googleAnalytics.LogScreen(new AppViewHitBuilder().SetScreenName("main_menu"));
This line is called after googleAnalytics.StartSession() so should be fine.
Just as a reference, here is my line to send GA event (which works and is visible in analytics console):
googleAnalytics.LogEvent(new EventHitBuilder().SetEventCategory("event_category").SetEventAction("event_action"));
I can't figure out what's the issue, as events are working fine, but LogScreen is not.
I would expect to see LogScreen shown in Active Page feed in GA real-time overview tab, but I can't see it, neither there nor anywhere else.
I have tested it on Android device only, Android 9, Xiaomi Mi8 Pro.
Also important notice: when running inside Unity IDE, it has no errors thrown but no data (even session and events) are not shown in GA console. Session and events ARE visible in GA console when running on mobile device.
Any directions on what am I doing wrong would be greatly appreciated!
I would use something else. GA is shutting down. Maybe you get the error because GA might restrict the access for the new comers. Your code seems okay.
https://www.semetis.com/en/resources/publications/google-will-shut-down-analytics-for-mobile-apps-in-2019

Initialize the Fire SDK on Unity for IOS

I just started a project in Unity and I integrated FireBase Analytics.
After some problems I was able to get data from IOS and Android devices so I added some custom events.
I followed the instructions from here and I stared to see results in the dashboard . My problem is that I'm not sure if both IOS and Android are sending the events and I don't know how to separate the event in the dashboard. I'm particularly concerned because I'm not sure if I misunderstood this line of the instructions:
The Firebase Unity SDK on Android requires Google Play services, which must be up-to-date before the SDK can be used. The following code should be added at the start of your application to check for and optionally update Google Play ....
I assumed that the following code had to be added ONLY for Android so I didn't add it to IOS. Can you tell me if I had add this code for IOS too? and how can I check the events for every OS?
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
// Create and hold a reference to your FirebaseApp, i.e.
// app = Firebase.FirebaseApp.DefaultInstance;
// where app is a Firebase.FirebaseApp property of your application class.
// Set a flag here indicating that Firebase is ready to use by your
// application.
} else {
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
Thank you in advance
Well, I was looking for all the day and I found that the filter between OS is in the top left corner of dashboard and event tap as well.
I also used the code for both IOS and Android and I started to get custom event in IOS too.

Firebase Dynamic Links - Can't get Url in android after install app from play store

If I install the app when clicking the dynamic link. All of that information from dynamic should be still available when I open the app for the first time.How can I get that information? It is not working when I use this: getInitialLink() returns Promise<string|null>;
Since, you haven't mentioned - I'm assuming you are having problems with shorter urls, if that's the case try putting the longer url.
Or refer here on Simon's answer: When I use the long instead of short links, everything works perfectly fine.
On Android, you use the getInvitation() method to get data from the Dynamic Link:
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, false).setResultCallback
(/* ... */);
Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:
Firebase Documentation - Use Case
For future reference or detailed answer on Firebase Dynamic Links
Behave just like normal Links
In cases where the application doesn’t require installation (say, if it’s already installed) then clicking the Dynamic Link will automatically open the link to the desired screen.
Dynamic Links have a very simple process flow:
The user begins by clicking the Dynamic Link
If the the needs of the Dynamic Link target are satisfied (this is, the application being installed) then the user is navigated to the target location
Otherwise, if the application requires install in order to navigate
to the Dynamic Link target, the the user is taken to the point of
install for the application. Once the application has been installed,
the user is navigated to the target location of the Dynamic Link
And if that wasn’t all, we can integrate Dynamic Links with Firebase Analytics to track the interaction with any links that we generate for our applications. But if we only require simple tracking, then we can use the automatic built-in analytics from the Dynamic Links panel within the Firebase Console where we can also obtain attribution and referrer information for interacted links with no extra effort required from our side.
What makes it different from Google Analytics?
One of the first things that came to my mind when I read about Firebase Analytics was, “What about my Google Analytics setup?”. So if you already have Google Analytics in place, then why would you make the switch to Firebase Analytics? Well, here’s a couple of differences between the two:
Audiences
We can use Firebase Analytics to create Audiences — these are groups of users that we can then interact with using other Firebase service such as Firebase Notifications and / or Firebase Remote Config.
Integration with other Firebase Services
An awesome thing with Firebase Analytics is that we can integrate other Firebase services with analytics. For example, creating an Audience of users who have experienced a crash reported through Firebase Crash Reporting.
Lower Method Count
The Google Analytics dependency on Android has a total count of 18,607 methods and has a total of 4kb used for dependancies. On the other hand, Firebase Core (for Analytics) has a method count of 15,130 and only 1kb used for dependancies.
Automatic Tracking
When we add the firebase core dependency, it will automatically begin tracking a collection of user engagement events and device information for us — this is useful if you’re looking to only collect the minimal data for your app.
Unlimited Reporting
For up to 500 events, Firebase Analytics provides us with unlimited reporting straight out of the box for free!
No Singleton Initialisation
When setting up Google Analytics on Android we are required to initialize a Singleton instance. Firebase Analytics are simply available by fetching the instance directly from where we wish to track data. This isn’t much effort obviously but just makes the setup flow slightly easier.
Single Console
All of the data for every Firebase service is available for a single console. That makes it both easier and quicker for us to navigate from checking the analytic stats for our app to viewing the latest crash reports.
It looks like this is a react-native-firebase open bug for android
For fix the only thing that is required to be changed in module code:
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null;
}
to
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData);
if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) {
return true;
}
return false;
}
Bug reference : https://github.com/invertase/react-native-firebase/issues/1273
Please Check Your Manifest file
open AndroidManifest.file => In your activity tag there is intent-filter tag put below line in that tag.
<data android:scheme="https" android:host="your.dynamic.link" />
<data android:scheme="http" android:host="your.dynamic.link" />
If already done then check this link for the full blog on the dynamic link with react native.
Link: http://blog.logicwind.com/react-native-dynamic-links-using-firebase/
I hope this will help. sorry for the typos.

Event is not logged on Firebase

I'm using Firebase on my Android app.
I'm using this package for my react-native project. I don't get any errors when I'm using it. However, events are not logged. Any help with this? Thanks!
I'm implementing the code like:
Analytics.setUserId(user.uid)
Analytics.logEvent('view_item', {
'item_id': 'login'
});
If you read this (Firebase documentation), you can see that it's a custom event, the custom events not appear on control panel but you can see that in audiences and as a filters for firebase analytics. If you want that your event is showed in your control panel you need to use a general events, you can learn more about them here, when you use the user properties or regular events the firebase needs 24h hours to recompile information and show it on control panel. Tell me if I helps you! Greetings!
When your code triggers a "view_item", it is supposed to "trigger" an existing event from the firebase analytics console.
So you need to create an event that will handle the "view_item" event in your code.
From the console in analytics, you need to create a new event named "view_item_trigger" for example add the following condition:
"if event_name is equal to 'view_item' ".
The view_item_trigger event will now appear in the debug view

Categories

Resources