AI-Powered Performance MarketingGuardrails and AI-powered reporting · Lesson 14 of 15

AI-powered reporting and anomaly detection

Article · 8 min · 8 min lecture

Video lecture

AI-powered reporting and anomaly detection

14 chapters · about 8 min · full transcript

Coming soon

Chapter 1 of 14

AI-powered reporting

  • From dashboards to decisions
  • A reporting architecture
  • Trustworthy anomaly rules
  • Honest AI narratives

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

From dashboards to decisions

Most marketing reports describe what happened. Useful reports explain why, flag what is unusual, and recommend what to do next — with the uncertainty stated. AI can now handle much of the grunt work: pulling data, spotting anomalies, drafting narratives. The analyst's job shifts to defining the right metrics, checking the reasoning and making decisions.

A reporting architecture that works

  1. Collect: platform APIs or connectors (Google Ads, Meta Marketing API, TikTok, LinkedIn), GA4 export to BigQuery, backend orders.
  2. Model: a clean table per day × channel × campaign with spend, platform conversions, backend orders (where attributable), new customers, margin.
  3. Detect: rules and simple statistics flag anomalies (spend spikes, conversion drops, CPA outliers, tracking breaks).
  4. Explain: an LLM receives the numbers and the anomalies (not raw access to everything) and drafts a narrative with hypotheses.
  5. Review: a human checks, edits and decides.
  6. Distribute: weekly memo, Slack summary, dashboard.

Looker Studio, Power BI and similar tools remain the dashboard layer; AI adds the narrative and triage.

Anomaly detection you can trust

Start with simple, explainable rules before machine learning:

  • Tracking break: conversions = 0 for a campaign that averaged > 10/day.
  • Spend anomaly: today's spend > 1.5× the trailing 14-day median for the same weekday.
  • Efficiency drift: 7-day CPA outside the 28-day mean ± 2 standard deviations.
  • Data gap: backend orders vs platform conversions ratio changes sharply (often a tag or consent problem).

Hands-on: anomaly flags plus an LLM narrative

import os, json
import pandas as pd

df = pd.read_csv("daily_channel_metrics.csv", parse_dates=["date"])
# columns: date, channel, spend, conversions, backend_orders
df = df.sort_values("date")
flags = []
for ch, g in df.groupby("channel"):
    g = g.set_index("date")
    last = g.iloc[-1]
    base = g.iloc[-29:-1]
    if base["conversions"].mean() > 10 and last["conversions"] == 0:
        flags.append({"channel": ch, "type": "tracking_break"})
    med = base["spend"].median()
    if med > 0 and last["spend"] > 1.5 * med:
        flags.append({"channel": ch, "type": "spend_spike", "spend": float(last["spend"]), "median": float(med)})
    cpa = (base["spend"] / base["conversions"].where(base["conversions"] > 0)).dropna()
    last_cpa = last["spend"] / last["conversions"] if last["conversions"] else None
    if last_cpa and len(cpa) > 7 and abs(last_cpa - cpa.mean()) > 2 * cpa.std():
        flags.append({"channel": ch, "type": "cpa_outlier", "cpa": round(last_cpa, 2), "mean": round(cpa.mean(), 2)})

summary = df[df["date"] >= df["date"].max() - pd.Timedelta(days=6)].groupby("channel")[["spend", "conversions", "backend_orders"]].sum()
payload = {"week_summary": summary.round(2).to_dict(), "anomalies": flags}

prompt = f'''You are a performance marketing analyst. Using ONLY the data below, write a weekly memo:
1) Three headline findings with numbers. 2) Each anomaly: likely causes (as hypotheses) and the check to confirm.
3) Recommended actions, each with expected impact and risk. If data is insufficient, say so. Do not invent numbers.
DATA: {json.dumps(payload)}'''

# Send `prompt` to your approved LLM provider's API, reading the key from an environment variable, e.g.:
# api_key = os.environ["LLM_API_KEY"]
print(prompt[:500])

Keep the model's input to aggregated, non-personal data. Store prompts and outputs so you can audit how a recommendation was made.

Prompting for honest narratives

  • Tell the model to use only provided data and to label hypotheses as hypotheses.
  • Ask for the check that would confirm each hypothesis (for example, "compare tag firing in Tag Assistant").
  • Require numbers to be quoted from the data; spot-check them.
  • Ask for "what would change my mind" — it surfaces uncertainty.

What a good weekly memo contains

  1. Scoreboard — spend, backend new customers, blended CAC and margin after ads versus plan and last week.
  2. What changed and why — two or three findings, each tied to a number and a hypothesis.
  3. Anomalies — what was flagged, what was checked, what was fixed.
  4. Tests — status of running experiments and any results with intervals.
  5. Decisions needed — options, recommendation, risk. Keep it to one page; link to the dashboard for detail.

Worked example: an agency in Lahore serving UK clients

A 12-person agency reports for 20 UK e-commerce clients. They built a nightly pipeline: connectors into BigQuery, anomaly rules, and an LLM-drafted memo per client. Account managers now spend Monday morning reviewing flagged issues rather than building slides. The first month caught three tracking breaks within a day (previously found after a week). The agency discloses to clients that memos are AI-drafted and human-reviewed.

Pitfalls

  • Letting the LLM compute metrics from raw rows (it may miscalculate); compute in code, narrate with AI.
  • Sending personal data or confidential client data to unapproved tools.
  • Over-alerting: tune thresholds so people do not ignore alerts.
  • Reporting platform ROAS without the backend and incrementality context.

How to measure success

Time from issue to detection, analyst hours per report, share of recommendations acted on, and decision quality over time (did actions improve outcomes?).

Key takeaways

  • Useful reports explain why, flag the unusual and recommend actions with stated uncertainty.
  • Compute metrics and anomalies in code; let the LLM narrate aggregated results.
  • Start with simple, explainable anomaly rules: tracking breaks, spend spikes, CPA outliers, data gaps.
  • Prompt for hypotheses, confirming checks and 'what would change my mind'.
  • Keep personal and confidential data out of unapproved tools; log prompts and outputs.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. Why compute metrics in code before sending them to an LLM?
  2. Conversions dropped to zero for a campaign that averaged 40 per day, while spend was normal. What is the first hypothesis to check?
  3. Which prompt instruction best reduces fabricated narratives?

Put it into practice

Write three anomaly rules for your accounts with thresholds, and a prompt that turns weekly aggregated metrics into a memo with hypotheses and checks.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.