Skip to main content
All Collections3rd-party integrationsAnalytics
How to connect Batch to Firebase Analytics?
How to connect Batch to Firebase Analytics?

Learn how to track your Batch push and in-App campaigns in Firebase.

Selma avatar
Written by Selma
Updated over 10 months ago

Firebase Analytics, and in its latest form, Google Analytics for Firebase, is an extensive analytics solution that enables brands to measure relevant KPIs on their app and how their users interact with it. Those key metrics will enable Batch customers to get clear performance data of their campaign, and also better understand the behaviour of users in order to encourage conversion scenarios within the app.

You can easily establish this connexion by completing the following steps:

1. Installing the Firebase Dispatcher in Your Application

The Firebase dispatcher uses the UTM tags (like on a lot of Google services) from your campaign to dispatch a new set of data on Firebase.

Once the dispatcher is installed, you will be able to track different types of events related to your push or In-App messaging campaigns on Firebase.

If you haven't already installed the Firebase event dispatcher, please read our technical documentation for Android and iOS.

Note: The Google Analytics SDK has been sunsetted since October 2019 for non-Google Analytics 360 customers, meaning if you still use it on a free Google Analytics account, no data will be available and you must migrate to Firebase.

2.a. Tracking a push campaign with a UTM tag

The dispatcher gathers the values of utm_campaign, utm_source and utm_medium from the deeplink URL and from the custom payload of your campaign.

The tags utm_source and utm_medium are optional because they have a default value of batch and push accordingly.

You can add utm_content only in the deeplink URL in case your push notification has several different buttons.

2.b. Tracking an In-App Campaign or Mobile Landings

The dispatcher gathers the value of utm_campaign from the field Tracking ID of your campaign.

You can't customize the utm_source and utm_medium tags, they have a default value of batch and in-app accordingly.

You can add utm_content only in the deeplink URL in case your in-app message has two different buttons.

⚠️ Please note that the event dispatchers are only available from Batch's 1.15 SDK version and above. If you use an older version of Batch's SDK you can integrate the Firebase Batch plugin. However, this only allows you to track push opens and retrieve the campaign's UTM parameters.

Firebase plugin integration for older SDK versions

The plugin's job will be to read Batch's notifications clicks and extract the right parameters before sending them to Firebase.

Android:

Start by copying the FirebaseBatchIntegration class to your project. The code can be found here :

As shown in the BaseActivity example of the gist, you will have to call FirebaseBatchIntegration.handleIntent in every activity, both in onCreate and onNewIntent.

iOS:

Copy the FirebaseBatchIntegration class in your project. The code can be found here (Swift 4.2):

Then, as shown in the gist, simply call

FirebaseBatchIntegration.setup()

in applicationDidFinishLaunchingWithOptions before Batch.start(withAPIKey:)

If you call this method after starting Batch, the integration may work incorrectly.

Once you integrate the plugin, you can add your UTM parameters to your campaign's deeplink as described in section 2.a of this article.

3. Testing your campaign tracking

In order to test whether your Batch campaign data is correctly being tracked, you can use Firebase's Debug feature as follows:

a.Turning on the analytics debug mode

Android

Execute the following command to turn on the analytics debug mode on your Android device:

$ adb shell setprop debug.firebase.analytics.app package_name

Once you finish debugging, make sure you turn off the debug mode using this command:

$ adb shell setprop debug.firebase.analytics.app .none.

iOS

Specify the following line argument in Xcode to turn on the analytics debug mode on your iOS device:

-FIRDebugEnabled

Once you finish debugging, make sure you turn off the debug mode by specifying this line argument in Xcode:

-FIRDebugDisabled

b.Testing your integration

On Firebase, go to Analytics → DebugView. You should see your device and Batch events as soon as you receive, open a push or display, close, click an In-App message:


This article belongs to Batch's FAQ. Need more help? Find insightful articles, documentation, case & market studies, guides, and even more in our website's Resources section on batch.com and our blog.

Did this answer your question?