Google Analytics for Firebase: An API Alternative

Ameet Wadhwani Google BigQuery Leave a Comment

Recently our customers have been asking about Google Analytics for Firebase and whether they can use Canvas to connect to it.

YES! 

Analytics Canvas can access your Firebase data and integrate it into your reporting process. You can even use our new Cloud Automation service to keep your datasets refreshed as frequently as every 10 minutes for near real-time reporting.  

While Canvas connects to the Google Analytics API, Firebase data is not available through the Google Analytics API or through their own API just yet.  So in this post, we're going to show you how you can connect to Google Analytics for Firebase data through BigQuery using Analytics Canvas.  We'll use Tableau in this example, but since Canvas exports to a variety of formats, you should be able to get your data into your preferred reporting solution, whether it's Looker, PowerBI, Qlik, or something else. 

Google Analytics for Firebase

The Firebase console is your starting point. If you don’t have your own app yet, or if you don't have access to your app's data yet, it has a demo project that you can connect to both through the browser and BigQuery.

In the browser, you’ll see a very familiar look and feel and can easily navigate through the views.

 
Google Analytics for Firebase Console with sample app data

Not only that, but unlike Google Analytics, you can pull multiple apps into the same report right there in the console! It provides an aggregate view (you don’t get to see the data split out by app), but still, you’ve got a nice combined view without having to do any data prep.

However, if you’re already using something else to visualize your data, or if you need to clean, prep, and enrich your mobile app analytics data, you’ll need access to the raw tables.

Accessing raw data from Google Analytics for Firebase

Much like GA360, Firebase can be linked to BigQuery.  Also like GA360, within each BigQuery dataset for each app, a new table is imported for each day. That's right, 1 table for each day of app activity, for each app.

This definitely adds some complexity into your report routine. It means that you can’t simply point your reporting tool at an existing BigQuery table and expect to get meaningful results.

Furthermore, the data is not stored as a relational table, but rather some columns have nested fields. This means you have to know some SQL to get yourself some results.  There is an example provided below and Google also has some examples that you can customize on the Google Cloud Platform Blog that should help you get started.

Step by Step Guide to Get Google Analytics for Firebase into Tableau

  1. First things first – ensure that your app data is flowing into BigQuery or get access to the demo project's data in BigQuery.  
  2. If you don't already have it, get Analytics Canvas.  It's free for 30 days, and we don’t limit you at all, so go ahead, pull hundreds of millions of rows and use it all in your analysis. 
  3. Open Canvas and go to New Source > Google BigQuery > BigQuery SQL Query and make your first query.

Make a custom BigQuery SQL query with Analytics Canvas

Here's a sample query of Users by Date for the Firebase iOS demo app:

SELECT
  event_dim.date as eventDate, 
  EXACT_COUNT_DISTINCT( user_dim.app_info.app_instance_id ) as users
FROM
  TABLE_DATE_RANGE([firebase-public-project:com_firebase_demo_IOS.app_events_],TIMESTAMP( '{DateToText(DateOnly($AC_StartDate), "yyyy-MM-dd")}'), TIMESTAMP('{DateToText(DateOnly($AC_EndDate), "yyyy-MM-dd")}'))
GROUP BY
  eventDate

If you'd like to build a more complex query, but aren't quite sure how, check out this amazing video on BigQuery for Firebase by Todd Kerpelman at the Firebase Dev Summit 2017. 

Note the Table_Date_Range() function. This is super helpful for aggregating data across “wildcard tables”, those within the same BigQuery dataset with a similar name and a compatible schema.

The query also uses the Analytics Canvas Parameters $AC_StartDate and $AC_EndDate and some Canvas functions to format the date for the query. This allows you to use the date pickers in the Master Date Range to update all of your queries instantly. It also lets you easily make a relative date range selection (say the past 90 days), setting up your job for automation.

  1. Repeat step 3 until you’ve got a query for each app you’d like to pull into your analysis. For simplicity this example shows a query for both the iOS and Android apps, while the final visual includes data from 4 additional apps.
  2. Clean and process your data as needed using the data blocks in the Block Library.  In the workflow shown below, a filter block is used to remove rows that have a null value for eventDate, and a calculation block is used to add labels for the App type (iOS or Android), the BigQuery table in the query, and the name of the app.
  3. Add an Export block. In this case, the Canvas is exporting to a Tableau Hyper file and publishing to Tableau Server.
Google Analytics for Firebase prepared and published to Tableau Hyper
  1. Run the Canvas to generate the report table.

  2. Connect to your report table and visualize!
Google Analytics for Firebase sample data in Tableau

  1. To refresh this dataset on a schedule, simply go to the Automation menu, select Cloud Automation, then follow the wizard.

You did it! If you followed the steps above, you've been able to get data from Firebase into Canvas for processing, then onwards to Tableau where you can now include it as part of your reporting suite.

Why use Canvas when Tableau has a BigQuery connector?

Sure, you can get Firebase directly in Tableau using Tableau's BigQuery connector. But since raw data is not ready for analysis, you will have to do all of your data prep in SQL or with expressions in each Tableau workbook.  When business logic and data transformations are hidden in a workbook, they are difficult to audit, difficult to replicate and worse, easy to miss!

Canvas is your visual data layer, allowing you to add business rules and build a visual data pipeline.  This approach makes it easy to:

  • integrate data from other sources
  • audit and update the data preparation steps without complex SQL or hidden expressions
  • automate the report routine 

Not using Tableau?  Canvas can just as easily write your report tables to SQL Server, JSON, CSV, and more, where it can be easily accessed by most other BI tools.  

If you had any difficulty with the tutorial or if you'd like to go through this together with someone from our team, book a call with us using our convenient meeting planner.

About the Author

Ameet Wadhwani

Twitter Google+

Leave a Reply

Your email address will not be published. Required fields are marked *