Automate Analytics and Market Intelligence with n8n Workflows
n8n analytics automation pulls GA4 data, ad performance, and competitor prices into daily inbox reports automatically. No manual dashboards. Browse templates.
Stop Checking Analytics Dashboards by Hand
Dashboards don't surface insights. They wait for you to look. Most mornings that means six tabs, three logins, two spreadsheets, and a vague sense that nothing's changed since yesterday. Some mornings something has changed significantly and you find out four days later.
n8n analytics automation inverts the pattern: instead of you going to the data, the data comes to you, pre-analyzed, on a schedule, with an AI layer that flags what actually moved and writes a first draft of what to do about it.
This guide covers how to build those workflows for GA4, ad performance, competitor pricing, and market intelligence — and which templates skip the build entirely.
What You Can Automate With n8n Analytics Workflows
- Daily GA4 performance reports: sessions, users, conversions, and channel breakdowns delivered before the morning standup, flagged for bounce rate anomalies and zero-conversion segments
- AI-powered ad analysis: Google Ads and Facebook Ads campaign metrics fetched daily, underperforming campaigns identified, and GPT-4o-mini writes optimization recommendations per campaign
- Competitor price monitoring: daily scrapes of competitor product pages with immediate email alerts when any price shifts beyond a configurable threshold, plus AI-drafted response suggestions
- Market trend intelligence: weekly aggregation of Hacker News and Reddit trending topics, scored by engagement volume and analyzed for emerging niches and product gaps
- Threshold alerts: an IF node checks ROAS, conversion rate, or revenue against configurable bounds and fires a Slack or email alert the moment something breaks outside the range
- Weekly strategy briefs: a Google Sheets initiative tracker analyzed by GPT-4o-mini every Monday at 9am, delivered as an executive brief with priority actions and one decision to make
- Historical trend logging: every workflow run appends its output to Google Sheets, so week-over-week comparison requires no pivot table work
The n8n Analytics Pipeline
Every analytics n8n workflow follows the same backbone regardless of the source:
Schedule Trigger → HTTP Request (fetch data) → Code Node (normalize)
→ OpenAI Node (analyze, flag anomalies, write recommendations)
→ Code Node (parse model output)
→ IF Node (threshold check)
→ Gmail / Slack (alert or digest)
→ Google Sheets (historical log)
The IF node is the branching point. Metrics inside the normal range write to Sheets and stop. Metrics outside the acceptable range fire the alert branch with full context: what moved, by how much, and what the model suggests doing about it. Executions that don't alert don't clutter your inbox.
Step by Step: From Source to Report
1. Collect: Pull Live Data From Every Source
The n8n-nodes-base.httpRequest v4.2 node covers most analytics APIs directly. GA4 uses the Google Analytics Data API with OAuth2. Google Ads and Facebook Ads each have their own OAuth2 credential types in n8n. Competitor product pages need a plain HTTP GET with the competitor URL.
One catch worth knowing: GA4's Data API returns metrics and dimensions as separate parallel arrays, not flat per-row objects. You'll get metricValues[0] for the first metric column and dimensionValues[0] for the first dimension, and you have to zip them into records in the Code node. Copy-pasting a GA4 code example from 2022 won't help here — the v1 Data API response shape is different from the older Universal Analytics format most older tutorials show.
2. Process: Normalize Before the Model Sees It
Put a n8n-nodes-base.code v2 node between every data source and the OpenAI node. The jsCode parameter is where the normalization logic lives: null-checking, type coercion, unit conversion (Google Ads reports spend in micros — divide by 1,000,000 before passing it downstream), deduplication, date parsing.
Don't skip this during prototyping. The OpenAI node will produce confident-sounding output from malformed input. ROAS showing as 38,400% instead of 3.84 is a unit conversion bug that's obvious in retrospect but invisible when you're only reading the model's narrative summary.
The Google Analytics 4 Data API encodes every metric as a string, even numeric ones. A sessions count of 1,247 arrives as the string "1247". Parse every metric with parseInt() or parseFloat() in your Code node before passing values to an IF node or a calculation — otherwise the comparison sessions > 1000 is a string comparison, which sorts differently. This is documented in the GA4 API reference but easy to miss when looking at a response that looks correct.
3. Analyze: Let OpenAI Flag the Signal
This is where n8n analytics automation separates from a scheduled spreadsheet. The @n8n/n8n-nodes-langchain.openAi v2.1 node takes the normalized metrics, the previous period's numbers (pulled from a Google Sheets history log), and a structured prompt. Output arrives at $json.output[0].content[0].text.
The prompt matters more than the model tier. A prompt that says "Here are this week's ad campaign metrics and last week's for comparison. Flag any campaign where ROAS dropped below 2.0 or CTR dropped more than 20% week-over-week. For each flagged campaign, write one sentence on the likely cause and one concrete action." returns something you can act on. A prompt that says "Analyze these ad metrics." returns a paragraph you'd write yourself anyway.
GPT-4o-mini handles this class of analysis well. It's roughly 15 times cheaper than GPT-4o for tasks that don't need deep reasoning. Start there and upgrade only if the output quality doesn't meet the need.
4. Route: Alerts vs. Quiet Logs
An IF node after the parse step checks the model's structured output for flagged conditions. You can key off a boolean field the model returns (set the prompt to include "alert": true when something needs attention) or a numeric count (flagged_campaigns_count > 0). Executions where everything's inside range write to Sheets and exit. Executions where something triggered the alert run the email or Slack branch with the full context.
This is the part that gets skipped most often in analytics automation setups. Routing isn't optional. A workflow that emails you the same summary regardless of whether anything changed is something you'll stop reading within two weeks.
5. Deliver: Reports That Actually Land
For team reports, Slack messages with the three numbers that moved and a link to the full Sheets log work better than dense email digests. For founders and solo operators, an HTML email with narrative context tends to be more useful.
Build HTML templates in the jsCode parameter of a Code node, not inside the Gmail node's expression field. Once the HTML is more than a few lines long, editing it in a single expression field becomes error-prone and hard to debug. Keep template logic in the Code node where it's testable in isolation.
The App Analytics Dashboard template covers this end-to-end for GA4: it pulls session and conversion data daily broken down by channel and device type, flags segments with high bounce rates or zero conversions, generates AI-powered optimization notes via GPT-4o-mini (output parsed from $json.output[0].content[0].text), formats and emails the report, and logs every run to Google Sheets for trend comparison. Setup is around 20 minutes. The only configuration required is OAuth2 credentials for GA4, OpenAI, and Gmail.
Implementation Patterns
Pattern 1: Marketing Dashboard (GA4 and Ads)
Pulling from Google Ads and Facebook Ads alongside GA4 in a coordinated daily run:
Schedule Trigger (daily, 6:00am)
→ HTTP Request (Google Ads: campaign spend, conversions, ROAS)
→ HTTP Request (Facebook Ads: adset ROAS, reach, frequency)
→ HTTP Request (GA4: sessions by channel, bounce rate, goal completions)
→ Code Node (normalize all three into common schema: {source, campaign, spend, roas, ctr, sessions})
→ OpenAI Node (flag underperformers, write per-campaign recommendations)
→ Code Node (parse: alert_count, flagged_items[], summary)
→ IF Node (alert_count > 0)
YES → Gmail (flagged campaigns with recommendations)
NO → Google Sheets (daily log only)
The Ad Performance Optimizer template implements this pattern for Google Ads and Facebook Ads. It handles the OAuth2 differences between the two platforms (Google Ads uses a developer token plus OAuth2; Facebook uses a long-lived access token), normalizes spend units, and produces a formatted email with per-campaign ROAS analysis and GPT-4o-mini recommendations. For teams running more than a handful of active campaigns, starting from this template rather than building from scratch saves a significant amount of credential-wiring and normalization work.
Pattern 2: Competitor Price Intelligence
Schedule Trigger (daily, 7:00am)
→ Google Sheets Node (read product catalog: name, your_price, competitor_url, price_pattern)
→ HTTP Request (fetch each competitor page)
→ Code Node (extract price using configurable pattern, calculate delta and percent change)
→ IF Node (|delta_percent| > threshold)
YES → OpenAI Node (generate pricing response recommendation)
→ Gmail (alert: product, old price, new price, delta, AI recommendation)
→ Google Sheets (log this price check with timestamp)
NO → Google Sheets (log, no alert)
The Competitor Price Intelligence template runs this workflow with a Google Sheets product catalog where each row has its own price selector pattern. That means one workflow handles products with completely different competitor page structures without branching logic per product. The alert threshold is configurable per-product, not a global setting. Useful when you have premium products where a 2% shift matters and commodity products where you only care about moves above 10%.
Pattern 3: Weekly Market Intelligence Brief
For teams that want to know what's gaining traction in their category before it's obvious everywhere:
Schedule Trigger (weekly, Monday 5:00am)
→ HTTP Request (Hacker News Algolia API: top stories and comment counts)
→ HTTP Request (Reddit API: rising posts in target subreddits)
→ Code Node (deduplicate, score by engagement, filter noise, normalize)
→ OpenAI Node (identify 3-5 emerging themes, rate each on opportunity strength 1-10, flag gaps)
→ Gmail (weekly intelligence report: themes, scores, gap analysis, suggested experiments)
→ Google Sheets (log trend scores for week-over-week comparison)
The Market Trend Analyzer template implements this with Hacker News and Reddit as primary sources. It scores topics by engagement volume, passes them to GPT-4o-mini to identify emerging niches and product opportunities, and delivers a structured weekly report. Worth running for 4-6 weeks before acting on any single trend. One-week spikes aren't signals. Sustained week-over-week score increases are.
See all analytics and market intelligence templates →n8n Nodes You'll Use Most
| Node | Purpose |
|---|---|
n8n-nodes-base.scheduleTrigger v1.2 | Timed execution: daily, weekly, or hourly on a cron schedule |
n8n-nodes-base.httpRequest v4.2 | Fetch from GA4, Google Ads, Facebook Ads, competitor pages, news APIs |
@n8n/n8n-nodes-langchain.openAi v2.1 | AI analysis and recommendations; output at $json.output[0].content[0].text |
n8n-nodes-base.code v2 | Normalize responses, parse model output, build HTML reports (param: jsCode) |
n8n-nodes-base.if | Branch: alert path vs. log-only path based on threshold conditions |
n8n-nodes-base.googleSheets | Read product catalogs and config, log every run for trend analysis |
n8n-nodes-base.gmail | Deliver formatted HTML reports and targeted alert emails |
Getting Started
- Set up API credentials first. GA4 requires OAuth2 with the
analytics.readonlyscope enabled in Google Cloud Console. Google Ads needs a separate OAuth2 app with the Google Ads API enabled and a developer token. Both take a few minutes but they're where most builds stall. Don't skip ahead to the workflow until credentials work. - Build one data source at a time. Don't wire GA4, Google Ads, and Facebook Ads into the same workflow on day one. Start with GA4 only. Confirm the raw response shape, confirm the Code node normalizes correctly, confirm the OpenAI node returns something useful. Add the second source after the first one is solid.
- Use the Code node to inspect raw API responses. Set a temporary
return [$input.first()];in the Code node and trigger the workflow manually. Seeing the actual GA4 response shape once prevents a lot of guesswork about field names, array structures, and data types. It's a five-minute step that saves hours later. - Store thresholds in Google Sheets, not hardcoded in IF nodes. If you hardcode
roas < 2.0in the IF condition, changing it means editing the workflow. A Google Sheets Config row means changing a cell. Analytics thresholds shift with campaigns and seasons. Keep them editable without touching the workflow logic. - Start with GPT-4o-mini. Flagging underperforming campaigns, identifying trending topics, writing one-sentence recommendations: none of these require GPT-4o reasoning depth. GPT-4o-mini handles them well at a fraction of the cost. Upgrade only when you've confirmed the output quality isn't meeting what you need.
- Import the App Analytics Dashboard as your starting architecture. Even if you plan to heavily customize it, the credential wiring, Code node normalization patterns, and output structure are already correct. It's faster to modify a working template than to get the GA4 OAuth2 flow right from scratch.
For the scheduled reporting side of analytics (team metric snapshots, KPI reports, executive summaries), the n8n data reporting guide goes deep on those patterns. If you're new to using OpenAI nodes in n8n workflows, the n8n OpenAI workflows guide covers node behavior and the output path issues that trip up most first-time builds.
The real value of n8n analytics automation isn't the report. It's that the report is already in your inbox at 6:01am, filtered to exactly what moved, with a first draft of what to do about it. Dashboards require you to go looking. These workflows come to you.
Browse analytics and market intelligence templates →Common questions
How do I automate Google Analytics 4 reports with n8n?
Can n8n track competitor prices automatically?
What nodes does an n8n market intelligence workflow use?
Get the workflow templates this guide is built on
Import-ready n8n JSON, step-by-step setup, and tested end-to-end. One-time payment, own it forever.
More automation guides

Build a SaaS Automation Pipeline with n8n
Where SaaS Revenue Slips Through Before Anyone Notices SaaS products don't lose users at the cancellation screen. The window closes earlier: a trial expires with no follow-up, a free user hits the sto…

How to Automate Online Community Management with n8n
Managing an online community by hand means refreshing Reddit tabs, drafting the same invite emails over and over, and manually logging who received a coupon code. When a community exceeds a few hundre…

How to Run n8n in Docker: A Production Setup Guide
The official n8n docker quickstart gets you to a login screen. What it doesn't cover is the configuration that keeps n8n running six months later without silent failures, lost credentials, or executio…