---
title: "How to connect Firebase to Google Sheets"
description: "Learn how to connect Firebase with Google Sheets to better analyze your app data."
image: "https://images.ctfassets.net/lzny33ho1g45/5r84pDCh81iWe6QM9Ipzsf/79c4509c60c565fa15a5b83b3f34c6b0/connect-firebase-google-sheets-00-hero.jpg"
---

# How to connect Firebase to Google Sheets

Learn how to connect Firebase with Google Sheets to better analyze your app data.

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](https://zapier.com/apps/firebase/integrations/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](https://www.google.com/script/start/). Then, we'll do it in an easier, more flexible way—with Zapier.

### Table of contents

- [How to integrate Firebase with Google Sheets](#integrate-firebase-google-sheets)
- [Why you should create a Google Sheets Firebase integration with Zapier](#integrate-with-zapier)
- [Easy ways to connect Firebase to Google Sheets](#ways-to-connect)
- [How to connect Firebase to Google Sheets with Zapier](#how-to-connect)

## How to integrate Firebase with Google Sheets

One way to integrate Firebase with Google Sheets is by using [Google Apps Script](https://www.google.com/script/start/). 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](https://zapier.com/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.

### 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.

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](https://zapier.com/sign-up).

Once you're signed in, you can create new Zaps using the **Create Zap** button or by going to [zap.new](http://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**.

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"
    }]`

You can learn more about the correct syntax/structure [here](https://cloud.google.com/firestore/docs/reference/rest/v1beta1/StructuredQuery#Order). 

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.

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](https://help.zapier.com/hc/en-us/articles/8496008666509-Common-Problems-with-Firebase#creating-a-firestore-structured-query-for-a-trigger-0-0).

### 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.**

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.

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.

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

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.

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.