Sub topic 4
Data sources: ad platforms, analytics, CRM and the web
This chapter assumes you know basic marketing metrics, can read Python, and understand JSON and simple APIs. An agent can only report what it can reach, so you need to know where marketing data lives and how each source can mislead you.
The four source families
| Source | Examples | What it holds | Main risk |
|---|---|---|---|
| Ad platforms | Google Ads, Meta Ads | Impressions, clicks, spend, platform-reported conversions | Platform conversion counts often differ from your own |
| Web analytics | Google Analytics | Sessions, events, on-site conversions | Sampling and different attribution rules |
| CRM | HubSpot, Salesforce | Leads, deals, revenue, customer records | Personal data and incomplete fields |
| The web | Competitor pages, news, industry reports | Context and claims | Unverified content, outdated pages |
The first three are structured and come from systems you control. The web is unstructured and comes from strangers. Treat them differently.
How an agent reaches them
Each source becomes a tool (the next chapter covers tools). Behind the tool, one of three access paths is usually in use:
- An API call with a token, which gives fresh data.
- A scheduled export, such as a CSV in cloud storage, which is simpler but older.
- A search or fetch function for web pages.
Record where each number came from
Every result should carry its source, the date range and the time it was fetched. Without this, the agent cannot cite anything and a reviewer cannot check it. A simple freshness check catches stale exports:
from datetime import datetime, timedelta, timezone
def is_stale(fetched_at, max_age_hours):
"""Return True if the data is older than the allowed age."""
age = datetime.now(timezone.utc) - fetched_at
return age > timedelta(hours=max_age_hours)
record = {
"source": "ads_export.csv",
"date_range": "2026-10-01/2026-10-31",
"fetched_at": datetime.now(timezone.utc) - timedelta(hours=30),
}
print(is_stale(record["fetched_at"], max_age_hours=24))This prints True, so the agent should refresh the data or warn the reader.
Common errors
- Mixing definitions. An ad platform may count a conversion at click time, while the CRM counts it when a deal closes. Add the two together and you double count. Pick one definition per report and say which.
- Mismatched windows. Time zones and attribution windows differ between systems. Fix the date range and time zone in the tool's parameters, not in the prompt.
- Over-broad credentials. Give each tool a read-only token limited to the accounts it needs. An agent that can edit campaigns can also edit them by mistake.
- Obeying web text. A fetched page can contain sentences that look like instructions. Treat page content as data to summarize, never as commands, and record the URL for every claim.
- Pulling personal data you do not need. Request aggregated fields where possible. Later chapters cover privacy and access control in detail.
Exercise
A report combines ad-platform conversions (counted at click) with CRM deals (counted at close) and shows a total of both. Name the problem and one fix.
Show answer
The two counts use different definitions, so the same customer can be counted twice and the total is not meaningful. Fix it by choosing one definition for the report, or by reporting the two counts separately and labeling each with its source.