Loading
Loading
  • Home

  • Automation with Zapier

  • Zapier tutorials

Zapier tutorials

6 min read

How to connect Firebase to Google Sheets

By Will Harris · November 30, 2023
The header image for a blog post about integrating Firebase with Google Sheets.

In the realm of backend services, Firebase has made a name for itself as a powerful tool for building and managing apps. With real-time databases, analytics, and other cloud-based features, it's a great tool for gathering usage data and analytics.

Analyzing that data, however, isn't as easy. That's why a lot of Firebase users look to another Google product for that part—Google Sheets. By integrating Firebase with Google Sheets, you can pair the powerful data you get from Firebase with the data analysis and visualization that only comes with Google Sheets, helping you put the data you gather to use.

In this article, we'll walk through how to integrate Firebase with Google Sheets so you can automatically create a new Google Sheets row for every new document added to a collection in Firebase. First, we'll cover how to do this using Google Apps Script. Then, we'll do it in an easier, more flexible way—with Zapier.

New to Zapier? It's workflow automation software that lets you focus on what matters. Combine user interfaces, data tables, and logic with 6,000+ apps to build and automate anything you can imagine. Sign up for free.

Table of contents

How to integrate Firebase with Google Sheets

One way to integrate Firebase with Google Sheets is by using Google Apps Script. With this setup, you'll be able to periodically sync your data from Firebase to Google Sheets.

Here's how to do it:

1. Create a new Google Sheet or select the one you want to integrate with Firebase.

2. Click the Extensions tab from the menu bar and select Apps Script. This will open the Google Apps Script editor in a new tab.

3. Log into your Firebase Console and select the project you want to integrate.

4. Create a new database, or select the one you want to pair with Google Sheets, and copy the database URL.

5. Make sure that your database rules allow read access.

6. Back in the Google Apps Script editor, write a JavaScript function that uses the UrlFetchApp service to make HTTP GET requests to your Firebase database. For example:

function fetchDataFromFirebase() { var firebaseUrl = "YOUR_FIREBASE_DATABASE_URL";   var response = UrlFetchApp.fetch(firebaseUrl);   var data = JSON.parse(response.getContentText());   writeDataToSheet(data); }

7. Write a function to parse the JSON data and write it to your Google Sheet. For example:

function writeDataToSheet(data) {   var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();   // Code to parse data and write to the sheet }

8. Click the Save project icon, then run your script to test.

9. Check your Google Sheet to see if the data is imported correctly.

Why you should integrate Firebase and Google Sheets with Zapier instead

You can use the option above to connect Firebase and Google Sheets, but there are some serious limitations. 

For example, when you use Google Apps Script, you'll need to manually run your data each time you want to add data to a Google Sheet, which means your spreadsheet won't always be up to date.

With Zapier, on the other hand, you can pass data between Firebase and Google Sheets instantly and automatically, meaning your data is always fresh without you needing to do a thing. Plus, you can format your data exactly how you want it.

Oh, and Zapier connects with thousands of apps, so you can add any other tools into your workflow, if needed.

Easy ways to connect Firebase to Google Sheets

There are plenty of ways to integrate Firebase and Google Sheets. Tasks that could take hours out of your week, like extracting data from Firebase, can now happen in the background, freeing you up to do more important work. Here are some of the ways Zapier users automate their workflows between Firebase and Google Sheets.

To get started with a Zap template—what we call our pre-made workflows—just click on the button. It only takes a few minutes to set up. You can read more about setting up Zaps here.

Send data between Firebase and Google Sheets

Firebase helps you collect valuable user data and store it in a secure, reliable place. It's not a great place to analyze that data, though. By adding that data to Google Sheets, you'll get information that's a lot more user-friendly, allowing you and your team to easily glean valuable insights.

Create Google Sheets rows for new documents in Firebase / Firestore collections

Create Google Sheets rows for new documents in Firebase / Firestore collections
  • Firebase / Firestore logo
  • Google Sheets logo
Firebase / Firestore + Google Sheets

Likewise, if you're collecting valuable data in a Google Sheet and want to make sure it's backed up in a safe, secure cloud database like Firebase, you can automate that process, too. With the Zaps below, you can add new documents to Firebase every time a new row is added in Google Sheets, ensuring that all of your data is added automatically.

How to connect Firebase to Google Sheets with Zapier

Now, let's walk through how to connect Firebase to Google Sheets with Zapier. We'll use one of the workflows above—creating new Google Sheets rows for new documents in Firebase/Firestore collections.

Before you begin

Before you get started, you'll need to create a Zapier account if you haven't yet. Creating an account is free and easy—just head right here.

Once you're signed in, you can create new Zaps using the Create Zap button or by going to zap.new.

Set up your Firebase trigger

Once you're in the Zap editor, you'll need to create a trigger—the event that starts your Zap. Search for and select Firebase as the trigger app and New Document Within a Firestore Collection as the trigger event. Click Continue.

A screenshot of the setup for a Firebase trigger step in the Zapier editor.

Next, either click + Connect a new account if you haven't connected Firebase to Zapier yet, or select your account from the dropdown menu. Click Continue.

Now, customize your trigger. First, select the Firestore collection you want to connect to your Google Sheet from the dropdown.

Next, you'll need to enter a Structured Query to return the selected documents in the correct order, otherwise your Zap may never see the new documents.

The orderBy property in your query needs to ensure that the new documents are at the "top" of the search results, so that the Zap can see those documents. In most cases, you'll want to use DESCENDING, like this:

"orderBy": [{ "field": { "fieldPath": "someKeyOfYourChoice" }, "direction": "DESCENDING" }]

A screenshot of the Query field of the Firebase action step, with a JSON query entered.

You can learn more about the correct syntax/structure here. 

Once you've entered your Structured Query, click Continue.

Next, test your trigger. Zapier will look for a recent record in Firebase, according to how you set up your trigger earlier. You'll use this record to set up the rest of your Zap.

A screenshot of a successful Firebase trigger step test in the Zapier editor.

Once you get your test results, look them over to make sure everything looks right, then click Continue with selected record. Or, if something doesn't look right, try looking in our help doc.

Set up your Google Sheets action

Now it's time to set up your action—the event that your Zap performs when it's triggered. Select Google Sheets as your action app and Create Spreadsheet Row as your action event. Click Continue.

A screenshot of the setup for a Google Sheets action step test in the Zapier editor.

Next, connect your Google account if you haven't already, or select an existing Google account from the dropdown menu and click Continue.

Now it's time to customize your action step by telling Zapier what spreadsheet to add your data to and which data to put in which column.

Click in the Drive field and select which Google Drive your spreadsheet is in. Then click in the Spreadsheet field to select the specific spreadsheet and in the Worksheet field to select the specific worksheet you want to add your data to.

A screenshot of the "Drive", "Spreadsheet", and "Worksheet" fields in the Google Sheets action step setup.

After you select your worksheet, you'll see fields appear below for each column name. Note: the field names will look different for everyone depending on what values you put at the top of your worksheet.

Click one of the fields, and select which data you want to add from Firebase in the Insert data… dropdown.

A screenshot of Firebase data in the Insert Data... dropdown in the Zapier editor.

Do this for all of the column fields that you want to add data to. When you're done, click Continue.

A screenshot of Firebase data inserted into Google Sheets columns inside of the Zapier editor.

Now, it's time to test your action step. Click Test step, and Zapier will create a new spreadsheet row and populate it with the test data from your trigger step.

Once your test is run, open your spreadsheet to make sure that the data made it over properly.

A screenshot of a successful action step test with Firebase data added automatically to Google Sheets.

If something looks off, go back to your action step and tweak things before trying again. And if everything looks good, you're now ready to use your Zap.

Integrate Firebase and Google Sheets

Firebase is a great tool for collecting and storing data, but it's what you do with that data that counts. By integrating Firebase with Google Sheets, you can pass data back and forth between these two tools, giving you better insight into the data you have, and letting you store it all in a secure, cloud-based environment.

By doing it with Zapier, you can customize the integration to your exact needs, and be sure that your data is updated in real-time.

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags
mentioned apps

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'