Google Maps Lead Generation and Data Enrichment - n8n Workflow

Use this robust n8n workflow to automate lead generation. It scrapes Google Maps Places API data, handles rate limits with exponential backoff, and saves detailed business information directly to Google Sheets. A crucial n8n templates for marketers.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted text defining the user persona.

Marketing Agencies and Lead Researchers: Individuals needing high volumes of local business data.
Automation Specialists: Users looking for advanced examples of robust looping, API handling, and error management within an n8n workflow.
SaaS Sales Teams: Teams aiming to populate their CRM with verified geographical leads.
Data Engineers: Anyone requiring a reliable, scheduled data extraction solution built using n8n templates.

Overview

Generating high-quality, localized leads often involves repetitive manual searches. This n8n workflow solves this problem by creating a fully autonomous system for mass data extraction from Google Maps. It reads configuration (zip codes and business categories) from a Google Sheet, queries the Google Places API using a custom search query (e.g., 'plumber 90210'), extracts rich business details, and then cleans and imports that data back into a designated 'Results' Google Sheet.

A key feature of this n8n automation is its built-in API error handling. Since Google APIs frequently impose strict rate limits, the n8n node structure includes custom JavaScript for Exponential Backoff and a Wait n8n node. This mechanism ensures that if an API limit is hit, the workflow pauses, increases the delay time exponentially, and retries, preventing job failure and maximizing data throughput. This robust n8n template ensures reliable lead generation.

How it Works

This n8n workflow operates using two nested loops based on inputs from a configuration Google Sheet:


  1. Initialization and Setup: The workflow starts via the manual n8n trigger (or an optional scheduled n8n trigger). It first reads the essential configurations: the Google Sheet URL, the Zip Code Sheet Name, and the Category Sheet Name.

  2. Zip Code Loop (Outer Loop): The n8n node sequence retrieves all zip codes from the designated sheet. It uses a Filter n8n node to ensure only un-scraped zip codes are processed and applies a Limit to prevent excessively long executions.

  3. Category Loop (Inner Loop): For each selected zip code, the workflow retrieves the list of categories (subcategories) to search for (e.g., 'Dentist', 'Restaurant'). A Loop Subcats n8n node iterates through these.

  4. Google Maps API Request: The core operation uses an HTTP Request n8n node (labeled 'GMaps API') to query the Google Places API. The query combines the current Subcategory and Zip Code. It requests specific fields like phone number, website, rating, and address, ensuring comprehensive lead data.

  5. Data Transformation: The API response, which often contains an array of places, is processed by a Code n8n node ('Place Array'). This transforms the nested JSON structure so that each individual place becomes a separate item for processing by subsequent n8n nodes.

  6. Data Cleaning and Saving: Duplicate businesses (based on place.id) are removed. The enriched lead data is then inserted or updated into the primary 'Results' Google Sheet using the Add rows in Google Sheets n8n node.

  7. Rate Limit Management: Both the data writing and status update steps are wrapped with Exponential Backoff logic (implemented via Code and Wait n8n nodes) to gracefully handle Google Sheets API limits.

  8. Status Update: Finally, after successfully running through all defined subcategories for a given zip code, the Update Status to Success n8n node marks the zip code in the source sheet as 'scraped', ensuring the n8n workflow does not process it again.

Installation Guide

Markdown-formatted text detailing installation and setup.


  1. Importing the n8n Workflow: Copy the provided JSON code. In your n8n instance, navigate to 'Workflows', click 'New', and select 'Import from JSON'.

  2. Google Credentials Setup: This n8n workflow requires two main credentials:

Google OAuth2 API (for Maps API): You must configure a Google Cloud project and enable the Places API. Create a generic OAuth2 credential in n8n for this connection.
Google Sheets OAuth2 API: Set up a Google Sheets credential allowing read/write access to the configured spreadsheet.

  1. Configure Settings Node: Update the Settings n8n node with your specific Google Sheet URL (gs_url), the sheet name containing your categories (catSheet), and the sheet name containing the zip codes to process (sheet).

  2. Prepare Google Sheet: Ensure your spreadsheet contains at least two tabs corresponding to the names set in the Settings node (e.g., 'AZ Zips' and 'Google Maps Categories'). The zip code sheet must have columns like zip and status.

  3. Activation: Once credentials are set and configurations are verified, activate the n8n workflow and click 'Execute Workflow' to initiate the lead generation process.

Node Details

Markdown-formatted text detailing node specifics.

When clicking "Execute Workflow" (Manual Trigger): The starting n8n trigger used to launch the automation manually for testing or initial runs. Another option, Run workflow every hours, is provided as an alternative scheduled n8n trigger.
Settings (Set n8n node): Essential configuration point. Stores the primary Google Sheets document URL (gsurl), the category sheet name (catSheet), and the zip code sheet name (sheet).
GMaps API (HTTP Request n8n node): The core API interaction. Uses a POST request to places.googleapis.com/v1/places:searchText. Crucially, it utilizes the X-Goog-FieldMask header to specify exactly which fields (phone, website, rating, coordinates) should be returned, optimizing API usage and performance in this n8n workflow.
Place Array (Code n8n node): This custom n8n node script is vital for flattening the nested JSON response from the Google Maps API, ensuring each scraped location is handled as an independent item in the n8n workflow stream.
Add rows in Google Sheets (Google Sheets n8n node): Performs the final lead data storage. Uses the 'Append Or Update' operation to write extracted data points like title, phone, website, and gpscoordinates to the 'Results' sheet.
Exponential Backoff (Code n8n node): Implements advanced error handling. This specific n8n node calculates a retry count and exponentially increasing wait time, crucial for surviving frequent Google API rate limits. It is linked directly to a Wait n8n node to pause the n8n workflow before retrying failed Google Sheets operations.

Related n8n Workflows

Free

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by

n8n Ambassador & Verified Partner

Featured*