Meta Ad Library Video Analysis using Google Gemini and Google Sheets - n8n Workflow

Use this powerful n8n workflow to scrape Meta Ad Library video ads, analyze their content and effectiveness using Google Gemini's multimodal capabilities, and automatically log structured results to Google Sheets. Discover competitive insights instantly.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Ideal Users

Performance Marketing Analysts: Seeking automated competitive intelligence on successful video ad creatives.
Agencies & Media Buyers: Needing structured, AI-driven critique of competitor campaigns.
Marketing Technologists: Looking for advanced n8n templates integrating data scraping (Apify), multimodal AI (Gemini), and database operations (Google Sheets).
Data Engineers: Requiring an efficient n8n workflow for processing large volumes of external multimedia data.

Overview

Competitive analysis often involves manual review of marketing materials, which is time-consuming and prone to subjective errors. This advanced n8n workflow solves this by fully automating the scraping, filtering, AI analysis, and reporting process for video advertisements found in the Meta Ad Library.

The initial n8n trigger sets the stage, pulling raw data and then intelligently filtering it based on metrics like ad reach or duration (Calculate Runtime in Days and Sort by Reach or Days Running n8n node). Only video ads are passed forward. The core value of this n8n template lies in its use of Google Gemini's multimodal features. The n8n node sequence handles downloading the video, uploading it to the Gemini API, waiting for processing, and finally executing a detailed analysis prompt. By leveraging the Structured Output Parsing Agent, the workflow guarantees that the sophisticated analysis provided by Gemini is delivered in a clean, structured JSON format, ready for storage. This ensures reliable, objective insights are automatically populated in Google Sheets, making this n8n workflow indispensable for strategic marketing intelligence.

How it Works

The n8n workflow executes the following steps:


  1. Trigger and Initialization: The process begins with the When clicking ‘Test workflow’ manual n8n trigger. Initial nodes (Settings, Clean Prompt) define variables and prepare the input structure.

  2. Data Scraping: The Scrape Meta Ad Library with Apify n8n node uses an HTTP Request to pull a list of active advertisements.

  3. Data Refinement: The workflow calculates the runtime of each ad (Calculate Runtime in Days) and sorts the ads to prioritize the most relevant entries (Sort by Reach or Days Running). It then uses a Filter only Video Ads n8n node to discard static image ads.

  4. Limiting and Preparation: A Limit Videos to Analyze n8n node ensures that only a manageable batch of high-performing videos proceeds to the expensive AI analysis step, conserving compute resources. The Pass relevant Fields n8n node selects only the necessary data points before entering the loop.

  5. Iteration and Download: The Loop Over Items n8n node processes each selected video ad individually.

  6. Multimodal Setup: Inside the loop, the Download File n8n node fetches the video asset. The subsequent Code n8n node (Change Filetype to Video) prepares the data buffer for AI submission. The video is then uploaded via the Upload Video to Gemini HTTP Request.

  7. Synchronization: The Wait for Upload Processing n8n node pauses the execution until the video is indexed by the Gemini API, guaranteeing successful subsequent analysis.

  8. AI Analysis: The Analyze Video with Gemini HTTP Request, connected to the Structured Output Parsing Agent n8n node, submits the video reference and the prompt to Google Gemini. The Google Gemini Chat Model and Structured Output Parser work together to ensure the AI returns a standard, usable data object.

  9. Reporting: Finally, the Store Data Google Sheets n8n node appends the highly structured AI analysis (e.g., summary, effectiveness score, key hooks) into the specified Google Sheet, completing the automated n8n workflow.

Installation Guide

To deploy this comprehensive n8n template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'Import Workflow' function.

  2. Apify Credentials: You must provide credentials for the Apify platform (or a similar scraping service) used by the Scrape Meta Ad Library with Apify n8n node. This typically involves an API key.

  3. Google Gemini Setup: Configure the LangChain nodes (Google Gemini Chat Model and Structured Output Parsing Agent) with your Google API Key and ensure necessary services are enabled.

  4. Google Sheets Credentials: Create a new Google Sheets credential in n8n. In the Store Data Google Sheets n8n node, select this credential and configure the Spreadsheet ID and Sheet Name where you wish the analyzed data to be recorded.

  5. Adjust Limits: Review the Limit Videos to Analyze n8n node parameter. Adjust this number based on your budget and required depth of analysis.

  6. Testing: Execute the n8n trigger manually to ensure all connections (Apify, Gemini, Google Sheets) are functioning correctly.

Node Details

This n8n workflow utilizes several specialized and core n8n nodes:

When clicking ‘Test workflow’ (n8n trigger): Initiates the entire automation upon manual execution.
Scrape Meta Ad Library with Apify (HTTP Request n8n node): Sends a request to the Apify API endpoint to retrieve raw data from the Meta Ad Library based on configured search parameters.
Filter only Video Ads (Filter n8n node): Essential filtering step that processes the scraped results to ensure only items identified as videos proceed.
Loop Over Items (SplitInBatches n8n node): Controls the flow, ensuring each selected video ad is processed sequentially through the AI steps.
Download File (HTTP Request n8n node): Downloads the actual video file content from the URL provided in the scraped data.
Upload Video to Gemini (HTTP Request n8n node): Handles the initial API call to upload the video asset to the Gemini service for temporary storage and indexing.
Wait for Upload Processing (Wait n8n node): A critical synchronization n8n node that prevents the AI analysis request from failing by ensuring the video file is fully processed by Gemini.
Structured Output Parsing Agent (Agent n8n node): Orchestrates the AI analysis. It combines the Google Gemini Chat Model (the LLM) and the Structured Output Parser to interpret the video content and return insights in a standardized JSON schema.


  • Store Data (Google Sheets n8n node): The final action, using the 'Append Row' operation to save the structured, AI-analyzed data into the specified Google spreadsheet.

Related n8n Workflows

Paid

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by
Daniel Setzermann
Daniel Setzermann

Featured*