Back to Templates

Scrape B2B leads from Google Maps to Google Sheets with HasData

Created by

Created by: HasData || hasdata
HasData

Last update

Last update a day ago

Categories

Share


This n8n template shows how to build a complete B2B lead generation pipeline that scrapes Google Maps for businesses and enriches them with emails from their websites or Google search.

Use cases: Find local businesses with contact info for cold email campaigns, B2B prospecting, market research, or building CRM databases.

How it works

  1. You define search queries, locations, and page counts in a config sheet inside a Google Spreadsheet called "Leads".
  2. On each run, the workflow creates a new timestamped results sheet so previous runs don't get overwritten.
  3. It reads every row from config, generates paginated search tasks (20 results per page), and fires them at the HasData Google Maps API.
  4. Results get split into individual businesses. Duplicates are removed by name and place ID.
  5. For each business with a website, the HasData web scraper hits the URL directly and pulls any emails it finds.
  6. If no emails turn up on the website, or there's no website at all, the workflow runs a targeted Google search: "business name, city" email "@" and parses the organic results with a regex.
  7. All leads (whether emails came from the site or from Google) merge into one stream and get written to the results sheet: name, phone, address, website, emails, rating, reviews, type.

How to set up

  1. Install the HasData n8n node on your self-hosted instance.
  2. Connect your HasData API credentials and your Google Sheets OAuth2 credentials inside the workflow.
  3. In your Google Spreadsheet named Leads, add a sheet called config with these columns:
    • leads_query for the search term (e.g. coffee shops)
    • location for city, state, zip code, or a specific address
    • page_count for number of pages to fetch (20 results per page)
    • offset for starting page number (use 1 to start from the beginning)
  4. Click Manual Trigger to run.

Requirements

  • Self-hosted n8n (community node required)
  • HasData account with API key
  • Google account with Sheets API access (OAuth2)
  • Google Spreadsheet named Leads with a config sheet

Customizing this workflow

  • Swap the Manual Trigger for a Schedule trigger to run nightly lead generation automatically.
  • Add a filter node after "Remove Duplicates" to target only businesses above a minimum rating.
  • Extend the "Format Lead" nodes to capture additional fields from the Maps API like categories, hours, or social links.
  • Point the output to a CRM via HTTP Request instead of Google Sheets.

Further reading

The full build walkthrough, including real test results, node-by-node screenshots, and the regex logic behind the Google search fallback, is on the HasData blog: How to scrape leads with n8n.