# Google Sheets

Add every new form submission as a row in a Google Sheet with a short Apps Script that Nisuform generates for you.

The Google Sheets integration is available on Pro. Nisuform gives you a small Apps Script to paste into your spreadsheet. The script adds one row per submission and only accepts requests from your form.

## Connect Google Sheets

### Open the Apps Script editor

Open the Google Sheet you want submissions in. Choose **Extensions**, then **Apps Script**.

### Paste the script

In Nisuform, open the form's **Integrations** tab and choose **Google Sheets**. Copy the script from the dialog, replace the code in the Apps Script editor with it, and save.

### Deploy it as a web app

Choose **Deploy**, then **New deployment**, and pick the type **Web app**. Set **Execute as** to **Me** and **Who has access** to **Anyone**. Deploy, and allow access when Google asks.

### Paste the web app URL

Copy the web app URL. It starts with `https://script.google.com/` and ends with `/exec`. Paste it into the dialog in Nisuform, then choose **Send test** and check the sheet.

"Anyone" only means the script can receive requests without a Google sign-in. It doesn't share your spreadsheet. The script contains a token that belongs to your form and ignores every request without it.

## How rows are written

* Rows go to the first sheet in the spreadsheet.
* The first row holds the column headers. The script creates them and makes them bold.
* Every row starts with **Submitted at**, **Submission ID** and **Test**, which says `yes` for test submissions.
* Each answer goes in a column named after the field's label. When a new field shows up, the script adds a column for it at the end.
* Answers that start with `=`, `+`, `-` or `@` get a leading apostrophe, so the sheet never runs them as formulas.

You can rename the sheet, reorder columns and add your own columns next to them. Keep the header names the script uses, or it creates new columns.

## Troubleshooting

| Error                                 | Fix                                                                                                                           |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Google Sheets did not run the script. | The web app doesn't allow anonymous access. Deploy it again with **Who has access** set to **Anyone**, and paste the new URL. |
| The Apps Script rejected the request. | The script in the sheet doesn't match this form. Copy the latest script from Nisuform, paste it, and deploy again.            |

After you edit the script, choose **Deploy**, **Manage deployments**, and deploy a new version of the same deployment, so the URL stays the same. A new deployment gets a new URL, which you then have to paste into Nisuform.
