Updated 12 December 2023
Google Analytics for Firebase provides free, unlimited reporting on up to 500 distinct events. The SDK automatically captures certain key events and user properties, and you can define your own custom events to measure the things that uniquely matter to your business. Let’s see How to add Firebase Analytics in iOS app
Sometimes we need to track our application like (Most view page, most like the product, the number of logins, and places), etc. for that Google fireBase provides functionality.
Google Analytics helps you understand how people use your web, iOS, or Android app.
The SDK automatically captures a number of events and user properties and also allows you to define your own custom events to measure the things that uniquely matter to your business.
Once the data is captured, it’s available in a dashboard through the Firebase console.
This dashboard provides detailed insights about your data — from summary data such as active users and demographics to more detailed data such as identifying your most purchased items.
Google Analytics collects usage and behavior data for your app. The SDK logs two primary types of information:
Step 1: Before you begin, add Firebase to your iOS project. You can check here to add a firebase to your project.
Step 2: Now, add analytics SDK to your project.
1 |
pod 'Firebase/Analytics' |
Step 3: Then open AppDelegate file in your project and import Firebase.
Step4: Configure a FirebaseApp shared instance, typically in your app’s application:didFinishLaunchingWithOptions:
method:
1 |
FirebaseApp.configure() |
Please check the following example, how to log an event to check how many times particular Product Details are viewed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
var jeans: [String: Any] = [ AnalyticsParameterItemID: "SKU_123", AnalyticsParameterItemName: "jeans", AnalyticsParameterItemCategory: "pants", AnalyticsParameterItemVariant: "black", AnalyticsParameterItemBrand: "Levi's", AnalyticsParameterCurrency: "Rs", AnalyticsParameterValue: 1000.00 ] var productDetails: [String: Any] = [ AnalyticsParameterCurrency: "Rs", AnalyticsParameterValue: 1000.00 ] // Add items array productDetails[AnalyticsParameterItems] = [jeans] // Log view item event Analytics.logEvent(AnalyticsEventViewItem, parameters: productDetails) |
You can also check the code in Objective-C here.
Step6: To view this event in the Xcode debug console, enable Analytics debugging:
-FIRAnalyticsDebugEnabled
.Thanks for reading 🙂
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.