Part 1: Setting Up and Event Logging with Firebase Analytics in Flutter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this channel this is part one of our flutter Firebase analytics series we will dive into one of the most powerful tools at your disposal as a developer so let's start what is event logging event logging in simple terms is the process of recording specific interactions or occurrences within your application these interactions are known as events an event could be anything significant that happens in your app for example a user signing up for an account completing a level in a game or making a purchase let's touch on the benefits of event logging one is user Behavior Analysis by logging events you can get a clear picture of how users are using your app this can help you identify popular features and areas that might need Improvement the second is performance monitoring event logging can help you monitor the performance of your app if there are issues that affect user experience event login can help you pinpoint these and marketing insights if you're running marketing campaigns event logging can provide valuable insights and you can see which strategies are working which ads or driving conversions and adjust your approach based on data-driven insights there are two types of events the first type of events that Firebase analytics provides are automatically collected events these are events that Firebase automatically logs for you without any additional coding on your part examples of these include app install first open app updates and app removal these events provide you with fundamental insights into the life cycle of your app from a user's perspective the second type of events are custom events these are events that you define based on the specific actions or Milestones that are important to your app for example if you have an e-commerce app you might create a custom event for add to cart or complete purchase if you have a game you might create event for level up or game over one thing to note is that Firebase analytics does have some limits on the number of unique event names and parameters that you can use however these limits are quite high so most apps will never come close to reaching them let's go through some examples viewing a product suppose a user views a product in our app we want to log this as an event in this code product view is the event name and the parameters provide additional details about the product that was viewed both automatically collected and custom events can have parameters associated with them these parameters provide additional details about each event for example for the add to cart event parameters might include the item's name category and price and in this example the product view we have the parameters and they are set as string and dynamic because these are pairs so in the first section we have the name and the second we have the value of the parameter for example product ID product name and product category and then we have value for each one let's talk about the parameters more so the parameters Can Be Strings or numbers and there are up to 25 parameters allowed per event and remember that event name must be alphanumeric strings and cannot contain spaces or other special characters the maximum length for parameter names and string parameter values is 40 characters for Firebase analytics and note that while you can log many types of events and parameters only certain ones are used in Firebase analytics built-in report however you can always use bigquery service to analyze all your Raw event data if needed let's go through some more examples adding a product let's say a user adds a product to their cart we can log this event like so the name of the event is add to cart and then we have some parameters next example completing a purchase if a user completes a purchase we can log the event you can see the name is complete purchase and we have the parameters and in the last parameter notice that the value is a number while other values are string that's why we have the combination of string and dynamic next example is search event when a user performs a search in your app you can lock the search term the name is the search and we have the parameters if user signs up or logs in to your app you can log the event we have the name and we have parameters another example user level up event if your app is a game you can log when a user levels up including their new level and the amount of time they spent on the previous level we can have the name as level up and then we have the parameters new level and the time spent add click event if your app displays ads you can log when a user clicks an ad including the ad source and product promoted this is an example we have the name add click and we have parameters what is debugging events debugging events is the process of verifying that your events are being logged correctly it involves checking that the events you expect to see are indeed being sent to Firebase analytics and that the associated parameters are correct now we are going to talk about some best practices for using Firebase Analytics one is to understand your goals the first best practice is to understand your goals what do you want to achieve with your app are you looking to increase user engagement improve user retention or boost in-app purchases by understanding your goals we can determine which events are most important to log another one is log relevant events the next best practice is to log relevant events Firebase analytics allows you to log many different types of events but not all of them may be relevant to your app choose events that provide insights related to your goals use descriptive names another best practice is to use descriptive names for your events and parameters this makes it easier for you to understand your analytics data and for others on your team to understand Ended as well consistency is key when it comes to logging events make sure you are logging events consistently across different parts of your app and across different platforms if your app is available on multiple platforms this will ensure that your analytics data is accurate and comparable and lastly and perhaps most importantly respect user privacy Only log data that you need and ensure that you are in compliance with all relevant privacy laws and regulations so as an example let's add the Firebase analytics to the default counter application in flutter hubspect.yaml we need to add Firebase core and Firebase analytics after this we need to connect our application to the Firebase so we go to the Firebase project and in the Firebase project we can go to add app and you can select flutter or you can follow the iOS or Android separate flutter is pretty straightforward you can go through the installation of CLI if you don't have it and you click next you execute this command and then this command and it's going to add your app into your flutter project I have a video that shows you how to do this step by step I link it in the top right corner of this video you can follow that and then you can go to Project setting in the project setting you can scroll down and you can see the apps that you added to your project now inside our application this is the main.dart we import Firebase analytics Firebase core and Firebase options because when you use the flutter option to add your application to the Firebase it's going to create a new file called Firebase options so to use it we need to import it as well first we ensure the initialization and then we initialize our Firebase app in this way because this is going to use the Firebase options file and then we need to Define an instance of Firebase analytics and an observer we are going to talk about this Observer later then inside my home page we need to Define an instance of Firebase analytics and now the way we want to add analog an event in this application is when the user clicks on the floating button that adds to the counter we are going to log an event so basically when you want to log an event you need to go to the code where the event happens and then there you can add your event and log it so inside increment counter application after the counter is incremented we can add our log just like the examples that we saw earlier so in this case at analytics.log event we have the name for the log event and then we have the parameter the parameter is the counter and then inside the build function it's the same as before just like the default flutter application just underneath the text I have added a button let's run the app underneath the counter we have a button when you click this button it goes to the next page and I'm going to explain why we added this and then we have the floating action button that when user clicks the counter is incremented basically adding an event and logging an event is very straightforward you go to the location that event happens and you log it now we want to test this log event and we want to know if it works or not so for testing purposes you can go to terminal and you can run this command ADV shell set prop debug Dot firebase.analytics.app and then you need to provide your app package name for package name we are going to Android app and then source and then Main and we have Android manifest we open this file and at the top we have the package name so we are going to copy this package name and we're going to replace your package name with our package name in the command and then we enter and now we are going to run our application and you can see a debugger is available at this address so this way we know that it works in the debug mode now we go to the Firebase inside the Firebase in the analytics we go to debug view here you can see that there is debug device device which is zero you need to open this option and you need to click your device name if it doesn't appear you need to wait because it takes some time to connect flutter application to the Firebase analytics and it takes some time to appear on the device list so you can see that it shows screen view screen view this is almost real time take some time this is because we started the app and as you remember we have two types of event logging one is automatic and one is custom this screen view is the automatic event logging and the Firebase analytics automatically gathers some data and some events including this screen view but for the custom one remember that we have already implemented this log event name counter increment so we are going to increment our counter by pushing on The Floating Action button one two three and we go back to our Firebase and we wait as I said it takes some time now you can see we have our event logged here counter increment counter increment counter increment remember that we click the button three times so we have three logs for our event and if we click on the events we have more information the counter value is 2. remember in the code in the parameters we have the counter value and the value is the counter which means that if the counter is one the value here is going to be one and one is going to be logged if it is 2 2 is going to be logged so here we have the counter value of 2. if we click on another counter increment you can see that the value is 3. so these are some more information additional information the Firebase analytics gives you and that's the way you can test and debug your Firebase analytics now let's explore the Firebase analytics section in the dashboard you have an overall view of all the analytics that is happening number of users in the past 30 minutes the country and then which release are generating the event logs and engagement time we have the activities and so on in the real time analytics as you can guess it shows you the real-time events that happens in the application and on the events name you can see screen view five times counter increment two times actually it is three times but it takes some time to update and then inside events in the analytics you can see the events that are available and Firebase also suggests some events that you can add and Firebase automatically logs those events as well we are going to talk about other sections in the following videos we mentioned and we looked at the debug view already so inside the Firebase analytics if we go to the example we can see that there is an observer this Observer is a way to log users actions when the user goes from one page to another page and if you want to log that event you can add this Observer and that's why we have the Observer added to our app so from the beginning we have the Observer and we have the analytics in the my app class and you need to add this part to your material app Navigator observers Navigator observers Observer and then for example I added this button that when the user clicks it's going to direct user to the second screen and when I click on this button we go to the second screen and we go back so if we go to the debug View and we wait and now you can see the log appears here screen view if we click on it debug event 1 engagement time you can also use this engagement time for your analysis previous class previous ID previous screen it shows that the user comes from which screen Firebase screen and we have lots of parameters so using this Observer you can see if the user views a screen or page of your apps and you can analyze this data and do some analysis for your app I hope this was helpful thanks for watching I will see you in the next video
Info
Channel: Flutterware
Views: 11,906
Rating: undefined out of 5
Keywords: Setting Up and Event Logging with Firebase Analytics in Flutter, firebase, firebase analytics, flutter, app development, android, firebase tutorial, dart, google firebase, firebase flutter, google analytics, analytics firebase, how to implement firebase analytics with custom events, custom events, events, how to add event, flutter tutorial for beginners
Id: SEcEEVS2ZQo
Channel Id: undefined
Length: 19min 8sec (1148 seconds)
Published: Sun Jun 11 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.