Automate YouTube Competitor Video Analysis with n8n
Overview
This n8n workflow template automates competitor analysis for YouTube channels by extracting key performance data for their most engaging videos and storing it in Google Sheets. The workflow connects to the YouTube Data API to retrieve channel and video metadata, computes a simple engagement performance metric, then appends all results as structured rows in a spreadsheet.
Instead of manually checking views, likes, and comments for each video, this automation lets you submit a single input (a YouTube channel name) and receive an up-to-date, queryable dataset for ongoing analysis.
Workflow Architecture
The workflow follows a linear, data-driven architecture that transforms a user-provided channel name into a set of enriched video metrics. At a high level, it performs the following stages:
- Input collection – Capture the target YouTube channel name from a form.
- Channel resolution – Convert the human-readable channel name into a YouTube channel ID using the YouTube API.
- Video discovery – Retrieve video IDs for that channel using configurable filters such as maximum number of videos and ordering.
- Video enrichment – Fetch detailed video metadata and statistics (titles, descriptions, thumbnails, views, likes, comments).
- Performance calculation – Compute an engagement performance score for each video.
- Data persistence – Append the processed dataset into a specified Google Sheet.
Each step is implemented as one or more n8n nodes, chained together so that the output of one node becomes the input for the next. The workflow is designed for repeatable, low-maintenance use, with minimal manual intervention once configured.
Node-by-Node Breakdown
1. Input Node – Channel Name Submission
Purpose: Accept the YouTube channel name that you want to analyze.
Typical implementation:
- A form-based trigger node or a manual input node that collects a single text field representing the competitor channel name.
Data flow:
- Input: No prior input is required. The user manually submits the channel name.
- Output: A JSON object that includes the channel name, for example:
{ "channelName": "Example Channel" }
This node functions as the entry point to the workflow. All subsequent nodes reference this field when querying the YouTube API.
2. YouTube API – Get Channel ID
Purpose: Convert the channel name into a canonical YouTube channel ID, which is required for accurate video retrieval.
Key behavior:
- Queries the YouTube Data API using the provided channel name.
- Resolves the associated channel ID so the workflow can uniquely identify the channel.
Data flow:
- Input: The channel name from the previous node.
- Output: A JSON payload containing, at minimum, the resolved
channelIdalong with any additional metadata returned by the API.
If the channel name is ambiguous or not found, the node will typically return no channel ID or raise an API error. In those cases, you can add error handling or validation nodes around this step to stop the workflow or notify you when the channel cannot be resolved.
3. YouTube API – Fetch Video IDs
Purpose: Retrieve a list of video IDs that belong to the resolved channel, based on configurable search or listing parameters.
Core parameters:
- Channel ID: The ID obtained in the previous step. This ensures only videos from the correct channel are retrieved.
- Ordering: Determines how videos are sorted, for example by view count to focus on the most-watched or most engaging content.
- Video duration filters: Allows you to limit results to specific duration ranges (such as short, medium, or long videos), depending on your analysis needs.
- Maximum results: The number of videos to retrieve. This lets you control the size of the dataset, for example the top 10 or top 50 videos.
Data flow:
- Input: The
channelIdfrom the previous node and any configured filter settings. - Output: A collection of video IDs, typically as an array of objects where each item includes a
videoIdfield.
This node focuses on discovery only. It does not yet provide full statistics or descriptive information. Those are added in the next step.
4. YouTube API – Extract Detailed Video Data
Purpose: Enrich each video ID with detailed metadata and statistics.
Data retrieved:
- Snippet data:
- Video title
- Video description
- Thumbnail URLs and related metadata
- Statistics:
- View count
- Like count
- Comment count
Data flow:
- Input: The list of video IDs from the previous node.
- Output: For each video ID, a fully populated object containing both snippet and statistics fields.
The node typically runs once per video ID, either via n8n’s built-in iteration or by passing the entire array of IDs to the YouTube API. The result is a structured dataset that is ready for numeric computations and downstream reporting.
5. Calculation Node – Video Performance Metric
Purpose: Compute a simple engagement performance score for each video based on likes, comments, and views.
Formula:
((likes + comments) / views) * 100
This calculation returns an engagement percentage that reflects how many interactions (likes plus comments) occur relative to the total number of views. Higher values indicate videos that generate more interaction per view.
Data flow:
- Input: For each video, the
likeCount,commentCount, andviewCountfields from the YouTube statistics. - Output: The original video data, augmented with an additional field such as
engagementScorecontaining the computed value.
Edge case considerations:
- If
viewCountis zero or missing, the formula would cause a division by zero. In practice, you should guard against this by either:- Setting the engagement score to 0 when views are 0, or
- Skipping those entries in your calculation node.
- If likes or comments are missing, treat them as 0 to avoid invalid numeric operations.
The template uses this metric as a straightforward way to compare video performance, but you can extend or replace the formula in advanced scenarios.
6. Google Sheets Node – Append Data
Purpose: Persist all computed metrics and metadata as new rows in a Google Sheet for long-term tracking and analysis.
Behavior:
- Connects to a specified Google Sheets document and worksheet.
- Appends each video’s data as a new row, preserving your existing data and adding new entries at the bottom.
Data flow:
- Input: The enriched video objects from the previous node, including titles, descriptions, thumbnails, statistics, and the engagement score.
- Output: A confirmation from Google Sheets indicating that rows were successfully appended.
Once written, the data can be filtered, sorted, or visualized directly in Google Sheets or used as a source for additional reporting tools.
Configuration Notes
YouTube Credentials and API Configuration
- You must configure valid YouTube Data API credentials in n8n before running the workflow.
- Make sure the API key or OAuth client has permission to access the YouTube endpoints used for channel and video data.
- Be aware of YouTube API quota limits. Large result sets or frequent runs can consume more quota.
Google Sheets Credentials
- Set up Google Sheets credentials in n8n and authorize access to the target spreadsheet.
- Ensure the configured account has edit permissions for the specific Google Sheet where data will be appended.
Sheet Structure and Column Mapping
- Before running the workflow, create a Google Sheet with appropriate column headers, for example:
- Channel Name
- Video ID
- Title
- Description
- Thumbnail URL
- Views
- Likes
- Comments
- Engagement Score
- Map each field from the n8n items to the corresponding columns in the Google Sheets node configuration.
Filtering and Limits
- Use the video retrieval parameters to control:
- The maximum number of videos per run.
- The sorting criteria, such as view count, to focus on the most relevant videos.
- The duration range, if you want to analyze only short-form or long-form content.
- Adjust these settings to balance data depth with execution time and API usage.
Error Handling Considerations
- If the channel name is invalid or not found, the workflow may return empty results. Consider adding:
- A check after the “Get Channel ID” node to verify that a valid ID exists.
- A notification or stop condition if no channel ID is returned.
- For the engagement calculation, ensure that division by zero is prevented when view counts are zero.
- If Google Sheets fails to append rows due to permission or network issues, you can add retry logic or alerting nodes to handle such failures.
Use Cases and Benefits
Strategic Applications
- Competitor benchmarking: Automatically analyze which competitor videos drive the most engagement and identify recurring patterns in topics, titles, or formats.
- Trend detection: Spot emerging themes or content types before they become saturated, using engagement scores and view counts as early indicators.
- Historical tracking: Build a longitudinal dataset of competitor performance by running the workflow regularly and tracking changes over time.
- Data-driven content planning: Use the collected metrics to inform your own YouTube content strategy and prioritize formats that consistently perform well.
Advanced Customization Ideas
Extending the Engagement Metric
- Adjust the formula to weight likes and comments differently if needed.
- Incorporate additional YouTube statistics fields if they are available and relevant to your analysis.
Integrating AI for Deeper Insights
You can extend the template by connecting it with AI tools such as OpenAI to:
- Summarize the top-performing videos directly from their titles and descriptions.
- Generate topic suggestions or content ideas based on recurring patterns in competitor videos.
This adds a qualitative layer on top of the quantitative metrics already stored in your Google Sheet.
Scheduling and Automation
- Attach a scheduler or cron-based trigger to run the workflow on a regular cadence, such as daily or weekly.
- Combine with notification nodes to send a summary of newly discovered high-performing videos to your team.
Getting Started with the Template
To begin using this n8n workflow template for YouTube competitor video analysis:
- Open the template in n8n using the link below.
- Configure your YouTube and Google Sheets credentials.
- Set up your Google Sheet with the desired columns.
- Adjust the video retrieval filters and limits as needed.
- Run the workflow, enter the competitor channel name, and review the results in your spreadsheet.
Once configured, the workflow handles the entire data collection and metric calculation process for you.
Tip: Combine this template with additional n8n workflows to build a complete YouTube analytics stack, including automated reporting and AI-assisted content ideation.
