n8nflow.net logo

Analyze Facebook Ads & Send Insights to Google Sheets with Gemini AI

by JJ ThamUpdated: Last update 2 days agoSource: n8n.io
Loading workflow viewer...

Getting Started

<p>Stop manually digging through Meta Ads data and spending hours trying to connect the dots. This workflow transforms n8n into an AI-powered media buyer that automatically analyzes your ad performance, gives you a first-pass categorization of your creatives, and delivers the insights directly into a Google Sheet.</p> <p><a href="<https://youtu.be/hxQshcD3e1Y>" target="_blank">➡️ Watch the full 4-part workflow setup and tutorial on YouTube</a></p> <h2>About This 4-Part Automation Series</h2> <p>As a media buyer, I built this system to automate the heavy lifting of analyzing ad data and brainstorming new creative ideas. This template is the foundational first part of that larger system.</p> <ul> <li>✅ <strong>Part 1 (This Template): Pulling Ad Data & Getting Quick Insights.</strong> Automatically pulls data into a Google Sheet and uses an LLM to categorize ad performance.</li> <li>✅ <strong>Part 2: Finding the Source Files for the Best Ads.</strong> Grabs the video or image file for the ads that this workflow identifies as top performers.</li> <li>✅ <strong>Part 3: Using AI to Understand Why an Ad Works.</strong> Sends the best ads to Google Gemini for structured notes on the hook, transcript, and visual elements.</li> <li>✅ <strong>Part 4: Getting the AI to Suggest New Creative Ideas.</strong> Feeds all the insights back into the AI to generate new ad concepts, scripts, and creative briefs.</li> </ul> <h2>What This Specific Template (Part 1) Does</h2> <ol> <li><strong>Secure Token Management</strong>: Automatically retrieves and refreshes your Facebook long-term access token.</li> <li><strong>Fetch Ad Data</strong>: Pulls the last 28 days of ad-level performance data from your Facebook Ads account.</li> <li><strong>Process & Clean</strong>: Parses raw data, standardizes key e-commerce metrics (like ROAS), and filters for sales-focused campaigns.</li> <li><strong>Benchmark Calculation</strong>: Aggregates all data to create an overall performance benchmark for your account (e.g., average Cost Per Purchase).</li> <li><strong>AI Analysis</strong>: A "Senior Media Buyer" AI persona evaluates each ad against the benchmark, categorizing it as "HELL YES," "YES," "MAYBE," etc., with a full justification.</li> <li><strong>Output to Google Sheets</strong>: Updates your Google Sheet with the raw performance data and the new AI-generated insights.</li> </ol> <h2>Who is it for?</h2> <ul> <li>E-commerce Store Owners</li> <li>Digital Marketing Agencies</li> <li>Facebook Ads Media Buyers</li> </ul> <h2>How to set up</h2> <ol> <li><strong>Credentials</strong>: <ul> <li>Connect your <code>Google Gemini</code> and <code>Google Sheets</code> accounts in the respective nodes.</li> <li>This template uses NocoDB for token management. Configure the <code>Getting Long-Term Token</code> and <code>Updating Token</code> nodes, or replace this section with your preferred credential storage method.</li> </ul> </li> <li><strong>Update Your IDs</strong>: <ul> <li>In the <code>Getting Data For the Past 28 Days...</code> HTTP Request node, replace <code>act_XXXXXX</code> in the URL with your <strong>Facebook Ad Account ID</strong>.</li> <li>In both Google Sheets nodes (<code>Sending Raw Data...</code> and <code>Updating Ad Insights...</code>), update the <em>Document ID</em> field with your target <strong>Google Sheet's ID</strong>.</li> </ul> </li> <li><strong>Run the Workflow</strong>: Click 'Test workflow' to run your first AI-powered analysis!</li> </ol> <h2>Tools Used in This Workflow</h2> <ul> <li>n8n</li> <li>Facebook for Developers</li> <li>Google AI Studio (for Gemini)</li> <li>NocoDB (or your preferred credential database)</li> </ul>