Example Custom Events

Example 1: Tracking Button Clicks

Log an event when a user clicks a specific button in your app.

For Android:

Bundle params = new Bundle();
params.putString("button_name", "subscribe");
mFirebaseAnalytics.logEvent("button_click", params);

For iOS:

analytics.logEvent("button_click", parameters: [
"button_name": "subscribe" as NSObject
])

For Web:

logEvent(analytics, 'button_click', {
button_name: 'subscribe'
});

Example 2: Tracking User Sign-Ups

Log an event when a user signs up for your app.

For Android:

Bundle params = new Bundle();
params.putString("method", "email");
mFirebaseAnalytics.logEvent("sign_up", params);

For iOS:

analytics.logEvent("sign_up", parameters: [
"method": "email" as NSObject
])

For Web:

logEvent(analytics, 'sign_up', {
method: 'email'
});

Example 3: Tracking In-App Purchases

Log an event when a user makes an in-app purchase.

For Android:

Bundle params = new Bundle();
params.putString("transaction_id", "T12345");
params.putDouble("value", 9.99);
params.putString("currency", "USD");
params.putParcelableArray("items", new Parcelable[] {
new Item("P123", "Product Name", "Category")
});
mFirebaseAnalytics.logEvent("purchase", params);

For iOS:

analytics.logEvent("purchase", parameters: [
"transaction_id": "T12345" as NSObject,
"value": 9.99 as NSObject,
"currency": "USD" as NSObject,
"items": [
["item_id": "P123", "item_name": "Product Name", "item_category": "Category"] as NSObject
]
])

For Web:

logEvent(analytics, 'purchase', {
transaction_id: 'T12345',
value: 9.99,
currency: 'USD',
items: [
{ item_id: 'P123', item_name: 'Product Name', item_category: 'Category' }
]
});

Example 4: Tracking Feature Engagement

Log an event when a user engages with a specific feature in your app.

For Android:

Bundle params = new Bundle();
params.putString("feature_name", "chat");
mFirebaseAnalytics.logEvent("feature_engagement", params);

For iOS:

analytics.logEvent("feature_engagement", parameters: [
"feature_name": "chat" as NSObject
])

For Web:

logEvent(analytics, 'feature_engagement', {
feature_name: 'chat'
});

Adding Firebase Custom Events for Analytics Conversion

Tracking user interactions and understanding their journey within our app is important for driving engagement and optimizing our apps performance. Firebase Analytics provides a robust framework for logging custom events, allowing us to measure key actions that contribute to conversions. In this article, we will explore how to add Firebase custom events for analytics conversion in detail.

Similar Reads

What are Firebase Custom Events?

Custom events in Firebase Analytics are user-defined events that allow us to track specific interactions within our app. While Firebase automatically tracks some default events like first_open and app_open and custom events give us the flexibility to monitor particular actions relevant to our business goals such as button clicks, purchases, or feature engagements....

Why Use Custom Events?

Track Specific User Actions: Custom events help us to track specific user interactions that are critical to our app’s success. Measure Conversions: By logging custom events, we can measure conversion rates for key actions, such as sign-ups or purchases. Optimize User Experience: Understanding user behavior through custom events allows us to make data-driven decisions to improve the user experience. Custom Reporting: Custom events enable us to create detailed and tailored reports in Firebase Analytics....

Setting Up Firebase Analytics

Before understanding the custom events, we need to set up Firebase Analytics in our project:...

Adding Firebase Custom Events

Step 1: Define Your Custom Events...

Example Custom Events

Example 1: Tracking Button Clicks...

Analyzing Custom Event Data

Using Firebase Console...

Best Practices for Tracking Custom Events

Define Clear Objectives: Determine what you want to achieve with your custom events (e.g., track specific user actions, measure conversions). Track Relevant Events: Focus on tracking events that align with your business goals and provide actionable insights. Use Descriptive Event Names: Choose descriptive and consistent names for your custom events to ensure clarity and ease of analysis. Segment Your Audience: Use user properties to segment your audience and analyze their behavior more effectively. Monitor Regularly: Regularly review your custom event data to identify trends, patterns, and areas for improvement. Optimize Based on Insights: Use the data to make informed decisions and optimize your app for better user engagement and conversions....

Conclusion

Adding Firebase custom events for analytics conversion is a powerful way to track specific user interactions and measure key actions that contribute to your app’s success. By setting up custom events, logging relevant interactions, and analyzing the data, you can gain valuable insights into user behavior and improve your app....