AI Data Analytics Agent in n8n: Auto Insights from GA4, HubSpot and Sheets
Your dashboards are full of numbers, but nobody knows what to actually do with them. GA4 says sessions dropped 12%, HubSpot shows a pile of new leads, and your Google Sheet has revenue that doesn't line up with either. This article shows you how to build an AI data analytics agent in n8n that pulls data from GA4, HubSpot, and Google Sheets, analyzes it together, and sends you plain-English insights and recommendations on a schedule.
Instead of opening five tabs every Monday, you get a single message: "Organic traffic is down 12% week-over-week, but lead quality improved and the Stripe template page converted 3x better. Recommend doubling down on that landing page." That is the difference between a dashboard and an analyst.
The Problem: Dashboards Show Numbers, Not Decisions
Modern teams don't suffer from a lack of data. They suffer from a lack of interpretation. A typical founder or marketer touches at least three data sources every week:
- GA4 for traffic, sessions, conversions, and channel performance.
- HubSpot for leads, deal stages, and pipeline movement.
- Google Sheets for revenue, ad spend, or any manual tracking that lives outside the SaaS tools.
The problem is that each tool answers a narrow question in isolation. None of them tells you the story across sources: that your traffic spike came from a channel that doesn't convert, or that your best-performing campaign in HubSpot is invisible in GA4 because of broken UTMs. Connecting those dots is analyst work, and analysts are expensive, slow, and inconsistent.
An AI agent closes that gap. It reads all three sources, compares them against history, detects what changed, and explains what it means in language a human can act on, every single day, without being asked.
Skip the build. Get the ready-to-import n8n template → Get it on Gumroad
The Architecture: Pull, Analyze, Detect, Report
The workflow follows a clean four-stage pipeline. Each stage is a small, replaceable block, which is what makes n8n ideal for this: you can swap GA4 for Plausible or HubSpot for Pipedrive without rewriting the logic.
1. Scheduled Pull from Each Source
A Schedule Trigger kicks the workflow off on a cadence you choose, usually daily at 7am or every Monday morning. In parallel, three nodes fetch fresh data:
- A GA4 node (or HTTP request to the GA4 Data API) pulls sessions, users, conversions, and channel breakdown for the period.
- A HubSpot node retrieves new contacts, deal stage changes, and pipeline value.
- A Google Sheets node reads your revenue, spend, or KPI tab.
Each source is normalized into a simple JSON object so the AI receives clean, structured input rather than raw API noise.
2. AI Analysis
The three datasets are merged and passed to an AI Agent node. The prompt instructs the model to act as a senior data analyst: compare current numbers to the prior period, identify the three most important changes, and explain the likely cause of each. This is where the magic happens, because the model reasons across sources instead of reporting each one separately.
3. Anomaly and Trend Detection
Before or alongside the AI step, a Code node calculates week-over-week and month-over-month deltas and flags anything outside a normal range (for example, a metric that moved more than 20%). These flags are fed into the AI prompt so the narrative leads with what genuinely matters instead of restating every figure.
4. Narrative Report to Slack or Email
The AI's output is formatted into a clean report and delivered through a Slack node or an email node. The result reads like a memo from an analyst: a headline, three key insights, and a short list of recommended actions. No charts to decode, no spreadsheets to open.
Who This Is For
This pattern earns its keep for anyone who is data-rich but time-poor:
- Founders who need a Monday pulse on the business without becoming part-time analysts. One message tells them whether the week was good and why.
- Marketers who want to know which channels and campaigns actually drove pipeline, not just traffic, with the GA4-to-HubSpot connection made for them.
- Operations and RevOps teams who need early warning when a metric breaks, before it shows up as a missed target three weeks later.
Because the agent runs on a schedule and pushes results to you, it scales attention without scaling headcount. The same workflow can watch ten metrics or a hundred without complaining.
Step-by-Step: Building the Agent
- Add a Schedule Trigger. Set it to run daily or weekly at the time you want your report to land. Start with weekly while you tune the output.
- Connect GA4. Authenticate with a service account, then configure the node to pull sessions, conversions, and channel grouping for the current and previous period.
- Connect HubSpot. Use the HubSpot credential and pull new contacts and deals for the same window. Map the fields you care about, such as deal stage and amount.
- Connect Google Sheets. Point the node at your revenue or KPI tab and read the relevant rows. This is your source of truth for money.
- Merge and normalize. Use a Merge node followed by a Set or Code node to combine all three sources into one clean JSON payload.
- Add the detection logic. A Code node calculates deltas versus the prior period and tags anomalies above your chosen threshold.
- Configure the AI Agent. Feed it the merged data plus the anomaly flags, with a system prompt that defines its role, the format you want, and a hard limit of three to five actionable recommendations.
- Format and deliver. Pass the AI output to a Slack or email node. Use a simple template with a headline, insights, and recommendations.
- Test, then schedule. Run it manually a few times, refine the prompt until the tone and accuracy feel right, then let the Schedule Trigger take over.
Writing a Prompt That Produces Decisions, Not Summaries
The single biggest factor in whether this agent is useful is the prompt. A weak prompt produces a polite restatement of your numbers. A strong prompt produces a decision. The difference comes down to constraints and role.
Give the model a clear identity ("You are a senior growth analyst reporting to a founder who has 60 seconds"), force it to prioritize ("Surface only the three changes that most affect revenue this period"), and demand action ("End with two to four specific recommendations, each tied to the data point that justifies it"). Just as important, tell it what to ignore: metrics that moved within normal noise should not appear in the report at all. The anomaly flags from your Code node make this easy, because the model can lead with what your own logic already marked as significant.
One practical safeguard: instruct the agent to state its confidence and call out when two sources disagree. If GA4 shows strong traffic but HubSpot shows no new leads, you want the report to flag that mismatch as a possible tracking issue rather than silently averaging it away. That single instruction turns the agent into a data-quality watchdog on top of an analyst.
Common Pitfalls and How to Avoid Them
- Comparing the wrong windows. Always pull the current period and the prior period of equal length so deltas are honest. Comparing a partial week to a full week produces false alarms.
- Feeding raw API responses to the model. Normalize first. Clean, labeled JSON dramatically improves accuracy and cuts token cost.
- Over-reporting. If every metric shows up every day, people stop reading. Threshold your anomalies and let the agent stay quiet on calm days.
- No memory of past reports. Store each report in a sheet or database so the agent can reference last week and avoid repeating the same recommendation.
Why Build It in n8n
You could glue this together with scripts and cron jobs, but n8n gives you three things that matter: visual debugging so you can see exactly what each source returned, native integrations for GA4, HubSpot, Google Sheets, Slack, and major AI providers, and self-hosting so your business data never leaves your infrastructure. When a source changes its API or you want to add a fourth data feed, you edit one node instead of refactoring a codebase. You also get retries, error workflows, and execution logs for free, which is the unglamorous plumbing that keeps a scheduled job alive month after month.
The end state is a quiet, reliable analyst that works while you sleep and only speaks when it has something worth saying. That is the highest-leverage automation most small teams can run.
Ready to automate? Get this template on Gumroad →