Log new Gmail emails into Google Sheets for tracking and analysis
Every new email that matches your Gmail search gets a row in your tracking sheet with its sender, subject and preview, so the log builds itself for reporting.
Install it
Set up this Zap for me, read how here: https://zapier.sh/zapier/awesome-zaps/log-new-gmail-emails-to-google-sheets/
Paste into Claude, ChatGPT, Cursor or any agent.
- Category
- Data & Analytics · Data operations
- Author
- Zapier
- Source
- zapier/awesome-zaps, folder zaps/log-new-gmail-emails-to-google-sheets
Set it up with the CLI
- Add it. Copies the folder into
zaps/log-new-gmail-emails-to-google-sheets/. Outside a project, it makes one first.npx zap-pack add awesome-zaps/log-new-gmail-emails-to-google-sheets - Fill in the values in
config.ts, and in any other file the list marks. Replace each one as its comment and SKILL.md say. - Deploy it. Asks for any value still left, signs you in to Zapier if you aren't, then publishes it to your account.
npx zap-pack deploy log-new-gmail-emails-to-google-sheets - Check it. Its recent runs, with status and errors.
npx zap-pack logs log-new-gmail-emails-to-google-sheets
zaps/log-new-gmail-emails-to-google-sheets/
- README.mdWhat it does, for people
- SKILL.mdHow an agent sets it up: what to ask you, and how to test it
- config.tsIts settings 1 to fill in
- connections/gmail.tsThe
gmailaccount it uses - connections/google-sheets.tsThe
google-sheetsaccount it uses - triggers/search.tsWhat starts it:
gmailsearch1 to fill in - workflow.tsThe code; each
ctx.stepis a step in the Zap
Agents: add --yes to any command so it never prompts. When it needs an answer only the user can give, it stops and names the flag that supplies it.
SKILL.md
View MarkdownWhat it does
- Trigger: a new email matches the Gmail search you set (
gmail,search). - Google Sheets adds one row to the tracker worksheet with the time the email was logged, its Gmail message ID, the sender's name and email, the subject, and Gmail's preview text.
Every matching email gets a new row. The Zap only writes to the sheet; it never changes or deletes emails.
Ask the user
Each REPLACE_… value is set per person. Resolve names to IDs with the user's own connections; don't ask them to paste an ID you can look up.
| Setting | What goes there |
|---|---|
query (trigger) |
The Gmail search that picks which emails are logged, in Gmail search syntax, for example in:inbox or from:orders@example.com subject:invoice. |
SPREADSHEET_ID |
The tracking sheet: ask which sheet it is, then look up its ID (the long ID in its URL) with the user's Google Sheets connection |
Also review the defaults with them:
WORKSHEET_ID: the tab holding the tracker."0"is the first tab.LOGGED_AT_COLUMN,MESSAGE_ID_COLUMN,SENDER_NAME_COLUMN,SENDER_EMAIL_COLUMN,SUBJECT_COLUMN,SNIPPET_COLUMN: column keys such asCOL$A, not header names. Map the user's headers to their column letters, or leave a column out by pointing it at an empty column they don't use.
Build it
If you can run shell commands, set it up with zap-pack: run npx zap-pack add awesome-zaps/log-new-gmail-emails-to-google-sheets, replace each REPLACE_… value as this file says, then run npx zap-pack deploy log-new-gmail-emails-to-google-sheets, which signs the user in to Zapier when it gets there. Otherwise build with Zapier MCP, as the steps below say. No Zapier MCP tools? Read https://docs.zapier.com/mcp/get-started/quickstart.md and follow the page for the app you are running in to get the user connected, then continue with this build.
- Accounts: bind
gmailto the user's Gmail connection for the mailbox to log, andgoogle-sheetsto the connection for the account that owns the tracking sheet. - Source: publish
workflow.tsandconfig.ts, with eachREPLACE_…replaced by the user's answer.triggers/search.tsandconnections/are settings, not code: set the workflow's trigger and connection bindings from them. The trigger file names the app by its slug; for the trigger'sselected_api, callsearch_triggerswith that slug, find the row whosekeyissearch, and use<app_key>@<app_version>from it. - Build guide: load Zapier's build guide with
get_zapier_skill("zapier:build-workflows")and follow it to create, test and publish the workflow. - Fields: inspect the trigger's fields and the
add_rowaction's fields with the user's connections before the first test run, and fix any key inworkflow.tsthat doesn't match.
Test it
Run this sample as a draft test (run_workflow_draft in Zapier MCP), using a test email the user sent to themselves for this, not a real one:
{
"message_id": "18c0example",
"subject": "Test email for the tracking sheet",
"snippet": "This is a test email for the tracking sheet.",
"from": { "name": "Test Sender", "email": "test@example.com" }
}
Confirm that one new row appears in the tracker with the time, the message ID, the sender, the subject and the preview. If run-status tools aren't available, check the result in Google Sheets directly. The user deletes the test row, not the agent.
Notes
- Once the Zap is published and its trigger is active, every email matching the query adds a row. Keep the query narrow enough that the sheet stays useful.
- Google Sheets shows the logged time in the sheet's own format and time zone.
- Never commit a real spreadsheet ID or a real Gmail search that names a private person.