What is @react-native-firebase/analytics?
@react-native-firebase/analytics is a module for integrating Firebase Analytics into React Native applications. It allows developers to log events, set user properties, and track user interactions within their app, providing valuable insights for improving user experience and app performance.
What are @react-native-firebase/analytics's main functionalities?
Log Events
This feature allows you to log custom events to Firebase Analytics. The example logs an event when a product is viewed, including details like product ID, name, description, and price.
import analytics from '@react-native-firebase/analytics';
// Log a custom event
analytics().logEvent('product_view', {
id: '123456',
item: 'Product Name',
description: 'Product Description',
price: 29.99
});
Set User Properties
This feature allows you to set user properties that can be used to segment your audience in Firebase Analytics. The example sets a user property indicating the user's favorite food.
import analytics from '@react-native-firebase/analytics';
// Set a user property
analytics().setUserProperty('favorite_food', 'pizza');
Track Screen Views
This feature allows you to log screen views, which helps in understanding how users navigate through your app. The example logs a screen view for the 'HomeScreen'.
import analytics from '@react-native-firebase/analytics';
// Track a screen view
analytics().logScreenView({
screen_name: 'HomeScreen',
screen_class: 'HomeScreenClass'
});
Set User ID
This feature allows you to set a unique identifier for a user, which can be used to track user behavior across different devices and sessions. The example sets a user ID to 'user123'.
import analytics from '@react-native-firebase/analytics';
// Set a user ID
analytics().setUserId('user123');
Other packages similar to @react-native-firebase/analytics
react-native-google-analytics-bridge
react-native-google-analytics-bridge is a library for integrating Google Analytics into React Native applications. It provides similar functionalities like logging events and tracking screen views. However, it is specifically tailored for Google Analytics, whereas @react-native-firebase/analytics is designed for Firebase Analytics.
expo-firebase-analytics
expo-firebase-analytics is a package for integrating Firebase Analytics into Expo-managed React Native projects. It offers similar features such as logging events and setting user properties. The main difference is that it is optimized for use with Expo, making it easier to set up in Expo environments compared to @react-native-firebase/analytics.
react-native-mixpanel
react-native-mixpanel is a library for integrating Mixpanel analytics into React Native applications. It provides functionalities like event tracking and user property setting. While it offers similar features, Mixpanel is a different analytics platform compared to Firebase, with its own set of tools and capabilities.
React Native Firebase - Analytics
Analytics integrates across Firebase features and provides
you with unlimited reporting for up to 500 distinct events
that you can define using the Firebase SDK. Analytics reports
help you understand clearly how your users behave, which enables
you to make informed decisions regarding app marketing and
performance optimizations.
> Learn More
Installation
Requires @react-native-firebase/app
to be installed.
yarn add @react-native-firebase/analytics
Documentation
Additional Topics
License
Built and maintained with 💛 by Invertase.