Automated Competitor Content Gap Analyzer using AI and Google Sheets - n8n Workflow

Use this powerful n8n workflow to automatically crawl competitor websites, extract structured topic hierarchies and entities using Gemini AI, and save actionable insights directly into Google Sheets. Fast, data-driven content strategy.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • SEO Specialists and Digital Marketers looking for scalable competitor analysis.

  • Content Strategists who need structured, data-driven insights into rival topics.

  • Agencies performing content audits and gap identification for clients.

  • Users seeking pre-built n8n templates for integrating web scraping and AI capabilities.

Overview

Staying competitive requires understanding what your rivals are publishing. Manually mapping competitor content is time-consuming and error-prone. This specialized n8n workflow solves this by providing a hands-free, automated solution.

Triggered by a simple webhook (or form submission), the n8n workflow uses an Apify actor to crawl the specified competitor domain, capturing the raw page content in markdown format. It then sends this markdown to Gemini AI for deep, structured analysis. The AI is prompted to return a detailed JSON object containing hierarchical topics, content type classification, key entities, and a depth score.

Crucially, this n8n automation then dynamically creates a unique, dedicated tab within your Google Sheet document for the results, ensuring organized storage and easy analysis. Finally, a summary report is sent via Gmail, completing the fully automated feedback loop. This powerful n8n node combination transforms raw web pages into structured, actionable content strategy data.

How it Works

This high-utility n8n workflow operates in several key stages:


  1. Trigger and Input: The n8n trigger starts when a POST request hits the dedicated webhook. A Prepare Apify Input code n8n node processes and validates the request data (domain, email, crawl parameters) and prepares inputs for the crawler.

  2. Request Logging: The parameters of the crawl request are immediately logged into a central Google Sheets tab using a Google Sheets n8n node.

  3. Web Crawling: The Crawl Competitor Website Apify n8n node executes a high-speed web crawler, focusing on fetching content in markdown format based on the specified paths and depth.

  4. Data Fetching and Metadata: The crawled content dataset is retrieved via an HTTP Request n8n node. A subsequent Code n8n node extracts initial metadata (URL, word count, initial title) and passes the rich markdown content forward.

  5. AI Structured Analysis: The core intelligence resides in the LangChain AI Agent n8n node, which leverages the Gemini model. It strictly follows a defined JSON schema to map the content into hierarchical main topics and key entities.

  6. Normalization and Sheet Naming: The results from the AI are cleaned and normalized by a code n8n node. Another code n8n node dynamically generates a safe, unique sheet name based on the competitor URL, ensuring no naming conflicts in the Google Sheet.

  7. Data Storage: The Google Sheets n8n node first creates the new, dynamic tab. Then, the fully processed data (page URL, flattened topics, and keywords) is appended to that sheet.

  8. Reporting: Finally, an If n8n node checks if data was successfully generated. If so, a comprehensive HTML report is delivered to the requester via the Gmail n8n node.

Installation Guide

To deploy this effective n8n workflow, follow these setup steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Webhook Setup: Activate the workflow. The Start Here webhook n8n trigger node will generate a Production URL. This is the endpoint where your submission form or application must POST the competitor details.

  3. Credential Setup: This n8n workflow requires four critical credentials:

Google Sheets: Set up OAuth2 credentials for the Google Sheets n8n node. Ensure the account has write access to the target spreadsheet (Content Gap Analyzer in the example).
Apify API: Configure your Apify API key credential for the Crawl Competitor Website n8n node.
Google Gemini/PaLM: Set up the credentials for the language model chat n8n node (Analyze Page Content).
Gmail: Configure OAuth2 credentials for the Gmail n8n node to enable sending final reports.

  1. Google Sheets Configuration: Ensure you have a central Google Sheet document ready to receive the data. The initial logging step expects a tab named 'CONFIG'.

Node Details

Start Here (Webhook n8n trigger): The entry point of the n8n workflow, configured to listen for POST requests at the /competitors path.
Prepare Apify Input (Code n8n node): Crucial for transforming raw webhook JSON input into structured variables, normalizing the competitor domain, and setting crawl limits (maxpagesnum, crawldepthnum).
Crawl Competitor Website (Apify n8n node): Executes the Apify Web Content Crawler. Key configuration includes using dynamic startUrls and setting saveMarkdown: true to get content ready for AI analysis.
Fetch Crawled Dataset (HTTP Request n8n node): Retrieves the results from Apify's dataset API, pulling the collected markdown content.
AI Agent / Analyze Page Content (LangChain/Gemini n8n node): The core intelligence. This n8n node is configured with a detailed prompt instructing the AI to act as a content analyst and return a specific, hierarchical JSON schema for topic mapping.
Parse and Normalize Gemini JSON (Code n8n node): Handles error correction for the AI output, stripping markdown fences ( `json ) and flattening the complex topic tree into a readable bulleted list for Google Sheets.
Derive Sheet Name (Code n8n node): Generates a compliant and unique Google Sheet tab name (max 90 characters, safe characters only) based on the input URL.
Create sheet for the data (Google Sheets n8n node): Dynamically provisions a new worksheet tab using the name generated in the previous n8n node.
Save the data collected (Google Sheets n8n node): Performs the final write operation, appending the analyzed pageurl, maintopics, and key_words to the newly created sheet.
Send report (Gmail n8n node): Sends a final HTML-formatted email summary to the user specified in the original n8n trigger request.

Related n8n Workflows

Free

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

Featured*