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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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.


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.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free