Build a Data Analytics AI Agent: Automatic Business Insights from GA4, HubSpot, and Sheets Workflow with n8n
You already have the data. GA4 knows your traffic collapsed on Tuesday. HubSpot knows your MQL-to-SQL rate dropped 12% this month. That Google Sheet your ops team maintains knows your CAC crept above
You already have the data. GA4 knows your traffic collapsed on Tuesday. HubSpot knows your MQL-to-SQL rate dropped 12% this month. That Google Sheet your ops team maintains knows your CAC crept above target three weeks ago. The problem isn't data — it's that nobody has time to open three dashboards every Monday, cross-reference them, and figure out what actually changed. So the signal sits there, unread, until a quarter-end review surfaces a trend that started 60 days ago.
This article shows you how to build a Data Analytics AI Agent in n8n that runs every Sunday night, pulls GA4, HubSpot, and Google Sheets, detects the changes that matter, writes a plain-English executive summary, and drops it in your inbox and Slack before Monday standup. No dashboards to check. The insight comes to you.
The problem: dashboards don't tell you what changed
Dashboards are pull systems. They assume someone will show up, look, and interpret. For a busy founder or a two-person ops team, that assumption breaks every week. Three specific failures compound:
- Fragmentation. Traffic lives in GA4, pipeline lives in HubSpot, and the unit-economics math lives in a spreadsheet someone built by hand. No single screen shows all three.
- No baseline. A dashboard shows you 4,200 sessions. Is that good? You don't know unless you remember last week's number. Humans are bad at holding baselines in their heads.
- No prioritization. Even when you look, everything is presented with equal weight. A 3% wobble in bounce rate looks the same as a 40% cliff in demo requests.
The result is reactive operations. You find out about problems when they've already cost you a month. The fix isn't a prettier dashboard — it's an agent that watches the numbers for you and only speaks up when something is worth your attention.
The solution: a scheduled AI agent that reports by exception
The workflow is a push system. Once a week it does what an analyst would do: gather, compare against a baseline, flag the significant deltas, and narrate them in language a busy operator can read in 90 seconds. The architecture is deliberately simple:
- Trigger — a Schedule node fires Sunday at 20:00.
- Collect — three parallel branches hit GA4, HubSpot, and Google Sheets.
- Merge & compare — normalize each source, compute week-over-week deltas against stored baselines.
- Reason — an AI Agent node ranks the changes by materiality and writes the summary.
- Deliver — formatted HTML email + a Slack message to your leadership channel.
The key design choice is report by exception. The AI doesn't dump every metric. It's instructed to surface only statistically or operationally significant moves — a 15%+ swing, a metric crossing a target threshold, or a trend that's held for three consecutive weeks. Everything stable gets a one-line "no material change" so you trust the silence.
Step-by-step setup in n8n
Here's how the nodes connect. Assume you're on n8n 1.x with the LangChain nodes enabled.
1. Schedule Trigger. Add a Schedule Trigger node. Set the interval to Weekly, day Sunday, hour 20. This is your only entry point — keep the workflow otherwise passive so it never fires on a webhook by accident.
2. GA4 branch. Use the Google Analytics node with the "Get Report" operation, or an HTTP Request node hitting the GA4 Data API runReport endpoint if you need custom dimensions. Request sessions, totalUsers, conversions, and bounceRate for two date ranges: the last 7 days and the prior 7 days. Authenticate with a Google service account credential (OAuth2 works too, but a service account survives unattended runs).
3. HubSpot branch. Add the HubSpot node. Pull deals and contacts created in the window — operation "Get All" on Deals with a createdate filter, plus a search for contacts by lifecycle stage. What you want out of this branch: new MQLs, new deals created, deal-stage progression, and pipeline value. Use a Private App token credential rather than the legacy API key.
4. Google Sheets branch. The Google Sheets node with "Get Rows" reads your manual metrics tab — CAC, burn, custom KPIs your team tracks by hand. This is the escape hatch for anything the APIs don't expose. Point it at a named range so new columns don't break the read.
5. Merge and compute deltas. Feed all three branches into a Merge node (mode: "Combine", or "Append" if you'll flatten downstream), then a Code node. In the Code node, normalize each metric into a common shape — { name, current, previous, delta_pct, unit } — and compute the percentage change. Store the previous baseline either in the Sheet itself or in n8n static data via $getWorkflowStaticData('global') so week N always has week N-1 to compare against.
6. The AI Agent node. Add an AI Agent (or Basic LLM Chain) node with an Anthropic Chat Model connected as the language model — Claude Opus 4.8 or Sonnet 5 both handle this reasoning well; Sonnet is the cheaper default for a weekly job. Pass the normalized metrics array as input and use a system prompt like:
"You are a data analyst writing a weekly executive brief. Given these metrics with week-over-week deltas, identify only the changes that are material (≥15% swing, threshold crossings, or 3-week trends). For each, state the metric, the change, and one plausible driver. Rank by business impact. If nothing is material, say so. Output clean HTML: an h3 headline, then a bulleted list. No preamble."
Because the agent receives pre-computed deltas rather than raw rows, it reasons about meaning, not arithmetic — which is exactly where LLMs are reliable and where hand-rolled logic gets brittle.
7. Delivery. Split the agent output into two nodes: a Gmail (or SMTP) node sending an HTML email to your leadership list, and a Slack node posting to #exec-metrics. For Slack, wrap the summary in Block Kit so headings render; for email, the agent's HTML drops straight into the message body. Add a NoOp node after each as a clean terminus for logging.
Why this beats a BI tool or a manual review
- Zero-touch. After setup, it runs forever with no human in the loop. A BI dashboard still needs someone to open it.
- Cross-source synthesis. It's the only "analyst" that reads GA4, HubSpot, and your Sheet in one pass and connects a traffic drop to a pipeline dip.
- Narrative, not numbers. "Demo requests fell 38% week-over-week, concentrated in paid search" is actionable. A chart showing the same thing is not, until someone interprets it.
- Attention economy. By reporting only exceptions, it earns trust. When it goes quiet, you believe things are fine — so you actually read it when it doesn't.
- Cheap. One LLM call a week on Sonnet costs cents. Compare that to a per-seat BI license nobody logs into.
Common pitfalls and how to avoid them
Timezone drift on your date ranges. GA4, HubSpot, and n8n's scheduler can each interpret "last 7 days" in a different timezone, silently offsetting your windows. Pin every date calculation to one timezone in the Code node and pass explicit start/end dates to each API rather than relative ranges.
No stored baseline on the first run. Week one has nothing to compare against, so the agent either errors or hallucinates a delta. Seed the baseline manually in your Sheet or add a guard in the Code node that skips delta computation and reports raw values when previous is null.
Letting the LLM do math. Never ask the model to compute percentages from raw counts — it will occasionally be wrong and you won't catch it. Compute every number in the Code node; the LLM only ranks and narrates.
API rate limits and silent failures. If the HubSpot branch times out, a naive Merge node will hand the agent partial data and it'll report confidently on two sources as if that were the full picture. Add an IF node that checks all three branches returned data, and route failures to a Slack alert so you know the report is incomplete.
Alert fatigue from a loose threshold. If you set materiality too low, every run flags noise and you stop reading. Start at a 15–20% threshold, watch for a month, and tighten. The whole value of the system is that its silence is trustworthy — protect that.
Wire these six nodes together, set your thresholds, and you've replaced a recurring Monday-morning scramble with a report that writes itself. Your data was always talking. Now something is listening every week and only interrupting you when it counts.
Ja construimos isso pra voce
Nao comece do zero. O Data Analytics AI Agent: Automatic Business Insights from GA4, HubSpot, and Sheets e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.
Instalar por $79.0 →