Tech With Galvan
Back to Articles
AutomationFeb 7, 2029 • 5 min read

How to Automatically Capture Leads From Your Website Into Google Sheets

Capture website leads into Google Sheets automatically — no backend, no database. With form handling, email alerts, and a Python script.

Galvan
Galvan

Founder & Creator

Introduction

Every website needs a way to capture leads. But building a backend (database, API, admin panel) is overkill for a simple contact form. Google Sheets as a backend is the perfect solution: free, real-time, and your team already knows how to use it.

This post shows you 3 ways to capture website leads into Google Sheets — from no-code to fully custom.

Method 1: Google Forms (no-code, 5 minutes)

The simplest approach — embed a Google Form on your website.

Setup

  1. Create a Google Form with fields: Name, Email, Phone, Message
  2. Click “Send” → “Embed” → copy the iframe code
  3. Paste the iframe in your website

Pros

  • Zero code
  • Free
  • Responses go directly to a Google Sheet
  • Email notifications built in

Cons

  • Limited design customization
  • Google branding visible
  • Not great for professional sites

Method 2: Formspree + Google Sheets (no-code, professional)

Formspree handles form submissions and can forward to Google Sheets.

Setup

  1. Create a Formspree account (free: 50 submissions/month)
  2. Create a form → get your endpoint URL
  3. Add the form to your website:
<form action="https://formspree.io/f/YOUR_FORM_ID" method="POST">
    <input type="text" name="name" placeholder="Your Name" required>
    <input type="email" name="email" placeholder="Your Email" required>
    <input type="tel" name="phone" placeholder="Phone Number">
    <textarea name="message" placeholder="Message"></textarea>
    <button type="submit">Send</button>
</form>
  1. In Formspree dashboard → Integrations → Google Sheets → connect your sheet

Pros

  • Professional form (custom styling)
  • Spam protection built in
  • Google Sheets integration
  • Email notifications

Cons

  • Free tier limited to 50 submissions/month
  • Requires Formspree account

Method 3: Custom form + Python backend (full control)

For full control, build a custom form and handle submissions with a Python backend.

Frontend (HTML)

<form id="lead-form">
    <input type="text" id="name" placeholder="Your Name" required>
    <input type="email" id="email" placeholder="Your Email" required>
    <input type="tel" id="phone" placeholder="Phone">
    <textarea id="message" placeholder="Message"></textarea>
    <button type="submit">Send</button>
</form>

<script>
document.getElementById('lead-form').addEventListener('submit', async (e) => {
    e.preventDefault();
    const data = {
        name: document.getElementById('name').value,
        email: document.getElementById('email').value,
        phone: document.getElementById('phone').value,
        message: document.getElementById('message').value,
    };
    const res = await fetch('/api/leads', {
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify(data),
    });
    if (res.ok) alert('Thank you! We\'ll be in touch.');
    else alert('Something went wrong. Please try again.');
});
</script>

Backend (Python + FastAPI)

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import gspread
from google.oauth2.service_account import Credentials
from datetime import datetime

app = FastAPI()

@st.cache_resource  # or just create once
def get_sheet():
    creds = Credentials.from_service_account_file("service_account.json",
        scopes=["https://www.googleapis.com/auth/spreadsheets"])
    gc = gspread.authorize(creds)
    return gc.open("Leads").sheet1

@app.post("/api/leads")
async def capture_lead(request: Request):
    data = await request.json()
    
    # Validate
    if not data.get("name") or not data.get("email"):
        return JSONResponse({"error": "Name and email required"}, status_code=400)
    
    # Save to Google Sheets
    sheet = get_sheet()
    sheet.append_row([
        data["name"],
        data["email"],
        data.get("phone", ""),
        data.get("message", ""),
        datetime.now().isoformat(),
        "New",
    ])
    
    # Send notification
    send_lead_notification(data)
    
    return JSONResponse({"success": True})

Notification (email + WhatsApp)

import resend, os, requests

def send_lead_notification(lead):
    # Email
    resend.Emails.send({
        "from": "Leads <[email protected]>",
        "to": ["[email protected]"],
        "subject": f"New lead: {lead['name']}",
        "html": f"""
        <h3>New Lead</h3>
        <p><strong>Name:</strong> {lead['name']}</p>
        <p><strong>Email:</strong> {lead['email']}</p>
        <p><strong>Phone:</strong> {lead['phone']}</p>
        <p><strong>Message:</strong> {lead['message']}</p>
        """,
    })
    
    # WhatsApp (via WATI/Twilio)
    requests.post("https://live-server-XXXX.wati.io/api/v1/sendSessionMessage",
        json={"whatsappNumber": YOUR_PHONE, "messageText": f"New lead: {lead['name']} ({lead['email']})"},
        headers={"Authorization": f"Bearer {os.environ['WATI_API_KEY']}"})

Step 4: Google Sheets setup

Create a Google Sheet with these columns:

A: Name B: Email C: Phone D: Message E: Timestamp F: Status G: Source H: Notes

Status workflow

  • New → Just captured
  • Contacted → You reached out
  • Qualified → They’re a good fit
  • Proposal sent → Proposal delivered
  • Won → Became a client
  • Lost → Didn’t convert

Automation (Google Apps Script)

function onNewLead(e) {
  // Triggered when a new row is added
  const sheet = e.source.getActiveSheet();
  const row = e.range.getRow();
  const name = sheet.getRange(row, 1).getValue();
  const email = sheet.getRange(row, 2).getValue();
  
  // Send email notification
  MailApp.sendEmail("[email protected]", 
    `New lead: ${name}`, 
    `Name: ${name}\nEmail: ${email}\nCheck the sheet for details.`);
}

Method comparison

Method Setup time Cost Customization Best for
Google Forms 5 min Free Low Quick prototypes
Formspree 15 min Free (50/mo) Medium Professional sites
Custom (FastAPI) 1-2 hours Free (hosting) Full Full control

Common mistakes

  • No spam protection — add reCAPTCHA or honeypot to prevent spam
  • No validation — validate email format, required fields
  • No notification — you won’t know about leads until you check the sheet
  • No follow-up system — leads go cold if you don’t respond within 24 hours
  • Storing sensitive data — don’t store passwords or payment info in Sheets

Key Concepts

  • Lead capture = collecting contact info from potential customers
  • Google Sheets as backend = using Sheets as a simple database
  • Webhook = HTTP callback for real-time events
  • Honeypot = hidden field that bots fill but humans don’t
  • reCAPTCHA = Google’s spam protection

What to Try Next

FAQ

Google Sheets vs a real database?

Sheets is fine for <100 leads/day. For more, use a real database (Supabase, Postgres). Sheets has rate limits (60 req/min) and no complex queries.

How do I prevent spam?

Add a honeypot field (hidden input that bots fill but humans don’t) and reCAPTCHA. Also validate email format server-side.

Can I use this with WordPress?

Yes — use a plugin like “WPForms” or “Contact Form 7” with Google Sheets integration. Or use the custom HTML form approach above.

What if I get 1000+ leads?

Migrate to a real database (Supabase, Postgres) and use a proper CRM. Sheets works for small volumes; for scale, you need real infrastructure. See Streamlit + Supabase.