Firebase

Send your event data from RudderStack to Firebase.

Firebase is a popular mobile platform powered by Google. It helps you to quickly develop high-quality, enterprise-grade applications and grow your business.

RudderStack supports Firebase as a mobile device mode to which you can seamlessly send your customer data for analytics.

warning
Firebase device mode support is not available for the Cordova SDK.

Getting started

Before configuring Firebase as a destination in RudderStack, verify if the source platform is supported by Firebase by referring to the table below:

Connection ModeWebMobileServer
Device mode-Supported-
Cloud mode---
info
Firebase is a device mode-only integration. To learn more about the difference between cloud mode and device mode in RudderStack, refer to the RudderStack Connection Modes guide.

Once you have confirmed that the source platform supports sending events to Firebase, follow these steps:

  1. From your RudderStack dashboard, add a source. Then, from the list of destinations, select Firebase.
  2. Assign a name to the destination and click Next.

Connection settings

Connect this destination to your Android/iOS/Unity/React Native source. You should then see the following screen:

Firebase connection settings

As this is a device mode-only integration, click Next to complete the destination setup.

Adding device mode integration

Depending on your platform of integration, follow the steps below to add Firebase to your project:

Identify

The identify call sets the userId through the setUserId method from FirebaseAnalytics. RudderStack sets the other user properties from RudderTraits to Firebase using the setUserProperty method.

info
RudderStack ignores age, gender, and interest, as these properties are reserved by Google.
[[RSClient sharedInstance] identify:@"test_user_id"
                             traits:@{@"foo": @"bar",
                                      @"foo1": @"bar1",
                                      @"email": @"test@gmail.com",
                                      @"key_1" : @"value_1",
                                      @"key_2" : @"value_2"
                             }
];

Track

RudderStack’s track events are mapped to the standard Firebase events wherever possible.

Event mapping

RudderStack maps the following events to the standard Firebase events:

RudderStack EventFirebase Event
Payment Info Enteredadd_payment_info
Product Addedadd_to_cart
Product Added to Wishlistadd_to_wishlist
Application Openedapp_open
Checkout Startedbegin_checkout
Order Completedpurchase
Order Refundedrefund
Products Searchedsearch
Cart Sharedshare
Product Sharedshare
Product Viewedview_item
Product List Viewedview_item_list
Product Removedremove_from_cart
Product Clickedselect_content
Promotion Viewedview_promotion
Promotion Clickedselect_promotion
Cart Viewedview_cart

The following Firebase events are not mapped to any RudderStack event:

  • number_of_nights
  • number_of_rooms
  • number_of_passengers
  • origin
  • destination
  • start_date
  • end_date
  • travel_class
  • item_list_name
  • creative_slot
  • location_id
  • transaction_id
  • screen_class
info
RudderStack passes all event-related properties to Firebase. The nested values in the properties are converted to JSON using GSON.

Property mapping

RudderStack maps the following event properties to the standard Firebase properties:

RudderStack propertyFirebase property
categoryitem_category
cart_id,product_iditem_id
share_viamethod
querysearch_term
revenue, value, totalvalue
currencycurrency
taxtax
shippingshipping
couponcoupon
namename, promotion_name
quantityquantity
priceprice
payment_methodpayment_type
list_iditem_list_id
promotion_idpromotion_id
creativecreative_name
affiliationaffiliation

Along with mapping the above list of the standard property names, RudderStack exhibits the following behavior:

  • Converts the event names to the lower case.
  • Trims the whitespaces at the start and the end.
  • Replaces a space with an underscore.
info
Firebase enforces a strict event name length limit of 40 characters. RudderStack takes a substring of 40 characters (from the beginning) if the event names exceed this permitted value.

A sample track call sent from the iOS SDK is shown below:

[[RSClient sharedInstance] track:@"simple_track_with_props" properties:@{
    @"key_1" : @"value_1",
    @"key_2" : @"value_2"
}];

Screen

The screen method lets you record whenever a user sees their mobile screen along with any optional properties about the viewed screen.

A sample screen call is as shown:

[[RSClient sharedInstance] screen:@"Home Screen"
                              properties:@{
                                  @"Width" : @"13"
                              }];

Reset

The reset method resets the user identification.

A sample reset call is shown below:

Debugging

You can check the events and their properties in the Firebase DebugView. To enable it for Android, run the following command from your terminal:

$ adb shell setprop debug.firebase.analytics.app <your_package_name>

For iOS, specify the following in your command line argument in XCode:

-FIRAnalyticsDebugEnabled

FAQ

How do I disable automatic screen tracking while using the RudderStack SDKs?

  • For Android, nest the following setting within the <application> tag of your AndroidManifest.xml file:
<meta-data android:name="google_analytics_automatic_screen_reporting_enabled" android:value="false" />
  • For iOS, set FirebaseAutomaticScreenReportingEnabled to NO (Boolean) in your Info.plist.

For more information, refer to the Firebase documentation.


Questions? Contact us by email or on Slack