Generate Leads with Google Maps API Using n8n Automation

Struggling to extract accurate local business leads by zip code and category? This n8n workflow automates Google Maps API queries, deduplicates results, and records leads into Google Sheets to save hours and improve lead accuracy.
httpRequest
googleSheets
code
+13
Workflow Identifier: 1711
NODES in Use: manualTrigger, scheduleTrigger, executeWorkflowTrigger, if, stopAndError, httpRequest, googleSheets, set, code, removeDuplicates, wait, splitInBatches, splitOut, filter, limit, stickyNote
Automate lead generation with n8n and Google Maps API

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow collects local business leads from Google Maps by zip code and category.
It solves the problem of spending many hours searching and copying data manually.
The result is a list of clean and detailed business leads saved automatically into Google Sheets.

The workflow uses information from Google Sheets as input, calls the Google Maps Places API, processes the data, and writes unique leads back to Google Sheets.
It also manages errors and API limits to run smoothly.


How the Workflow Works

Inputs

  • List of zip codes from a Google Sheet.
  • List of business subcategories also from a Google Sheet.

Processing Steps

  • Loops through each zip code and subcategory pair.
  • Sends a search query to the Google Maps Places API with these details.
  • Checks if API returns any business places. If nothing found, skips to next.
  • Extracts each business place as an individual item.
  • Removes duplicates by checking place IDs.
  • Updates or adds lead information in the Google Sheets document.
  • Marks each zip code as “scraped” after the successful process.
  • Handles Google Sheets API limits with exponential backoff retry and waits.

Outputs

  • A Google Sheet populated with unique business leads including phone, rating, address, and website.
  • Status updates in the zip code sheet to track progress.

Who Should Use This Workflow

This is useful for marketers and salespersons who need local business leads often.
Also for anyone who wants to automate getting business data by zip code and category without errors or manual work.


Tools and Services Used

  • Google Sheets API: Reads zip codes and categories, writes results.
  • Google Maps Places API: Searches businesses by subcategory and zip code.
  • n8n platform: Orchestrates the automation with nodes and workflows.
  • Google OAuth 2.0: Provides secure API access.

Beginner Step-by-Step: How to Use the Workflow in n8n

Step 1: Import the Workflow

  1. Download the provided workflow file from this page.
  2. In your n8n editor, click “Import from File” and upload the workflow file.

Step 2: Add Credentials

  1. Open the credentials section in n8n.
  2. Add or select existing Google OAuth 2.0 credentials for Google Sheets API.
  3. Add or select Google OAuth 2.0 credentials for Google Maps Places API.

Step 3: Update Configuration

  1. Open the “Settings” node in the workflow.
  2. Update your Google Sheets document URL in the gs_url parameter.
  3. Check the sheet names for categories (e.g., “Google Maps Categories”) and zip codes (e.g., “AZ Zips”).
  4. Adjust any other IDs, emails, or table names if the workflow uses specific references.

Step 4: Test the Workflow

  1. Run the workflow manually to check it works.
  2. Look for error messages or issues in the execution logs.

Step 5: Activate for Production

  1. Switch to automatic triggers like the scheduled trigger to run periodically if desired.
  2. Activate the workflow in n8n by enabling it.
  3. Check outputs in Google Sheets after runs.

For larger scale use, consider self-hosting n8n to have more control and API limits.


Edge Cases and Failure Handling

The workflow checks when Google Maps API returns no places and moves on silently.

If Google Sheets API limits are hit, it uses exponential backoff code nodes that delay and retry calls.

After a max retry count, the workflow stops gracefully with an error message.

Duplicates are filtered out by place ID comparisons so no repeated leads are written.


Customization Ideas

  • Change the “textQuery” parameter in the Google Maps API node to add city or state for tighter search.
  • Add extra Google Maps fields like open hours or photos for more lead info.
  • Adjust batch sizes in loop nodes to balance speed vs API limits.
  • Switch from manual to scheduled triggers for automatic regular updates.

Sample Code for Place Extraction

The “Place Array” node uses this code to split results:

const places = items[0]?.json?.body?.places || [];
let output = [];
if (places.length > 0) {
  for (let i = 0; i < places.length; i++) {
    output.push({ json: { place: places[i] } });
  }
}
return output;

This code separates each place from the API response to make them individual items for processing.


Sample Exponential Backoff Code

To handle API rate limits, code nodes use this example logic:

// Define the retry count
const retryCount = $json["retryCount"] || 0;
const maxRetries = 5;
const initialDelay = 1;

if (retryCount < maxRetries) {
  const currentDelayInSeconds = initialDelay * Math.pow(2, retryCount);
  return {
    json: {
      retryCount: retryCount + 1,
      waitTimeInSeconds: currentDelayInSeconds,
      status: 'retrying'
    }
  };
} else {
  return {
    json: {
      error: 'Max retries exceeded',
      retryCount: retryCount,
      status: 'failed'
    }
  };
}

This stops the workflow after 5 tries and grows wait time between attempts.


Summary

✓ The workflow saves time by automating local business lead collection.
✓ Results are clean, unique, and detailed leads stored in Google Sheets.
✓ It handles API limits and errors without stopping unexpectedly.
→ Users get reliable and up-to-date lead lists by zip code and category.
→ Easy to setup and run inside n8n, with options for automation.


Automate lead generation with n8n and Google Maps API

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The workflow automates collecting local business leads by zip code and category using Google Maps Places API and saves unique leads into Google Sheets.
Duplicates are removed by comparing place IDs before adding leads into Google Sheets, ensuring only unique entries are saved.
The workflow checks for empty API responses and skips to the next zip code or category without errors.
Users can enable the scheduled trigger node in n8n and activate the workflow to run periodically without manual start.
Author
Written By
Ritu Sanjali

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.