ingest-exports
Part of the Marketing Analyst agent preset.
Ingest exports
Every number this bot reports comes from here. Nothing is typed from memory.
When to use
On every report, every reporting ask, every spend check, and whenever the user says new data has
landed.
Source order, every run
- Every signed-in platform, read live in my browser. For each platform in the ACCOUNTS
entry: open its reporting view, set the date range the job needs, set the breakdown to
campaign and day, read the table, and screenshot the view with the date range visible. Write
the rows to the ledger tagged source live, with the platform, the view, and the read date. A
login wall means the session expired, so handle it per connect-accounts rather than guessing.
- Exports, for every platform that is not signed in, and for history older than the platform
view offers. Steps 1 through 10 below.
- Nothing for a period. Say which platform and which date range is missing and stop. Do not
estimate, do not carry a previous period forward, and do not fill a gap from the ledger.
Live and export rows for the same platform, date, and campaign are the same key, so the dedupe
rule below applies across sources. The live read wins, because it is the platform's own current
number, and the drop is recorded in the check file.
Where exports come from
In this order, stopping at the first that has a file newer than the last ingest:
- The Google Drive folder the user named in setup.
- The Google Sheet and tab the user named in setup.
- A file the user pasted into chat, which lands under /workspace/uploads/.
- Nothing. Then the rule in source order 3 applies.
Steps (export path)
- List candidate files with their modified dates. Take the newest per platform that is not
already recorded in /workspace/analytics/exports/index.md.
- Copy the file unchanged to /workspace/analytics/exports//- and add
a line to exports/index.md: file, platform, date range covered, row count, ingest date.
- Validate the header row against /workspace/analytics/column-map.md for that platform. Required:
a date column, a campaign column, impressions, clicks, cost. Recommended: ad set, conversions,
conversion value, the named conversion column, device, and country when present.
- On a mismatch, stop for that file and report it: the expected column, the header actually
found, and the two or three closest candidates. Ask the user to confirm the mapping once, then
update column-map.md. Never guess a mapping that changes what a number means, and never map a
second conversion column onto the first.
- Normalize dates to YYYY-MM-DD. Platform exports use several formats, so read the column as text
and parse it explicitly rather than letting a tool infer it. Reject a row whose date does not
parse and count it under rows dropped.
- Normalize currency: read the currency from the export or the column map, keep the code with the
number everywhere, and never convert between currencies. Strip thousands separators and
currency symbols. Micros columns (cost in micros) are divided by 1,000,000 and the conversion
is noted in exports/index.md.
- Dedupe on the key date plus platform plus campaign plus ad set. When two rows share a key,
the row from the newer export wins and the older is dropped. Count and report duplicates
dropped. A re-export of an overlapping range is normal and must not double count spend.
- Append to /workspace/analytics/ledger.csv, one row per date per campaign, with the raw columns
as ingested plus the source. The source column reads
live <platform> <view> <read date> or
export <file name> <ingest date>, and it travels with the number into every report.
- Rebuild /workspace/analytics/metrics-history.csv, one row per period per platform per campaign,
for the periods the ledger now covers, with the derived metrics computed per the formulas
below. Rebuild rather than patch so a late re-export corrects history.
- Write a dated check to /workspace/analytics/checks/.md: platforms read live and the
views used, files read, rows kept, rows dropped and why, duplicates dropped, date range now
covered per platform and per source, columns that failed validation, expired sessions, and
any period that is still missing. Anything that needs the user goes to
/workspace/analytics/fixes/.md as a short numbered list.
Column map shape
One row per platform header in /workspace/analytics/column-map.md:
<platform> | <export header> | <canonical field> | <unit or format> | <notes>
Canonical fields: date, campaign, ad_set, impressions, clicks, cost, conversions,
conversion_value, plus any extra the user reports on. Keep the platform's own conversion column
name in the notes so a report can name it.
Metric formulas (the only ones used anywhere)
- CTR is clicks divided by impressions.
- CPC is spend divided by clicks.
- CPM is spend divided by impressions, times 1,000.
- Conversions come from the platform's own conversion column, with its name kept.
- CPA is spend divided by conversions.
- ROAS is conversion value divided by spend.
- A metric whose denominator is zero or whose input is absent is written "not available", never
zero and never estimated.
- Never add one platform's attributed conversions to another platform's unless the user confirmed
the attribution windows match. When they have not, report per platform and say why there is no
total.
Output
The counts line in chat: platforms read live, files read, rows kept, rows dropped, duplicates
dropped, date range per platform, and anything that needs the user. Then the check file path.
Nothing else.
Never
Edit an export in place. Write a number into the ledger that came from neither a live view nor an
export. Convert currency. Carry a previous period's figure forward as new. Report a period the
data does not cover. Change anything inside a platform while reading it.
1---2name: ingest-exports3description: "Use before every report, every reporting ask, and every spend check, and whenever new data lands. Reads every signed-in platform live first, then the export files, validates columns against the column map, dedupes, normalizes dates and currency, and stores everything under /workspace/analytics/ with its source."4metadata:5 source: https://skillmd.com/skills/brokep/ingest-exports6---78# ingest-exports910Part of the Marketing Analyst agent preset.1112# Ingest exports1314Every number this bot reports comes from here. Nothing is typed from memory.1516## When to use17On every report, every reporting ask, every spend check, and whenever the user says new data has18landed.1920## Source order, every run211. **Every signed-in platform, read live in my browser.** For each platform in the ACCOUNTS22 entry: open its reporting view, set the date range the job needs, set the breakdown to23 campaign and day, read the table, and screenshot the view with the date range visible. Write24 the rows to the ledger tagged source live, with the platform, the view, and the read date. A25 login wall means the session expired, so handle it per connect-accounts rather than guessing.262. **Exports**, for every platform that is not signed in, and for history older than the platform27 view offers. Steps 1 through 10 below.283. **Nothing for a period.** Say which platform and which date range is missing and stop. Do not29 estimate, do not carry a previous period forward, and do not fill a gap from the ledger.3031Live and export rows for the same platform, date, and campaign are the same key, so the dedupe32rule below applies across sources. The live read wins, because it is the platform's own current33number, and the drop is recorded in the check file.3435## Where exports come from36In this order, stopping at the first that has a file newer than the last ingest:371. The Google Drive folder the user named in setup.382. The Google Sheet and tab the user named in setup.393. A file the user pasted into chat, which lands under /workspace/uploads/.404. Nothing. Then the rule in source order 3 applies.4142## Steps (export path)431. List candidate files with their modified dates. Take the newest per platform that is not44 already recorded in /workspace/analytics/exports/index.md.452. Copy the file unchanged to /workspace/analytics/exports/<platform>/<YYYY-MM-DD>-<name> and add46 a line to exports/index.md: file, platform, date range covered, row count, ingest date.473. Validate the header row against /workspace/analytics/column-map.md for that platform. Required:48 a date column, a campaign column, impressions, clicks, cost. Recommended: ad set, conversions,49 conversion value, the named conversion column, device, and country when present.504. On a mismatch, stop for that file and report it: the expected column, the header actually51 found, and the two or three closest candidates. Ask the user to confirm the mapping once, then52 update column-map.md. Never guess a mapping that changes what a number means, and never map a53 second conversion column onto the first.545. Normalize dates to YYYY-MM-DD. Platform exports use several formats, so read the column as text55 and parse it explicitly rather than letting a tool infer it. Reject a row whose date does not56 parse and count it under rows dropped.576. Normalize currency: read the currency from the export or the column map, keep the code with the58 number everywhere, and never convert between currencies. Strip thousands separators and59 currency symbols. Micros columns (cost in micros) are divided by 1,000,000 and the conversion60 is noted in exports/index.md.617. Dedupe on the key date plus platform plus campaign plus ad set. When two rows share a key,62 the row from the newer export wins and the older is dropped. Count and report duplicates63 dropped. A re-export of an overlapping range is normal and must not double count spend.648. Append to /workspace/analytics/ledger.csv, one row per date per campaign, with the raw columns65 as ingested plus the source. The source column reads `live <platform> <view> <read date>` or66 `export <file name> <ingest date>`, and it travels with the number into every report.679. Rebuild /workspace/analytics/metrics-history.csv, one row per period per platform per campaign,68 for the periods the ledger now covers, with the derived metrics computed per the formulas69 below. Rebuild rather than patch so a late re-export corrects history.7010. Write a dated check to /workspace/analytics/checks/<date>.md: platforms read live and the71 views used, files read, rows kept, rows dropped and why, duplicates dropped, date range now72 covered per platform and per source, columns that failed validation, expired sessions, and73 any period that is still missing. Anything that needs the user goes to74 /workspace/analytics/fixes/<date>.md as a short numbered list.7576## Column map shape77One row per platform header in /workspace/analytics/column-map.md:7879`<platform> | <export header> | <canonical field> | <unit or format> | <notes>`8081Canonical fields: date, campaign, ad_set, impressions, clicks, cost, conversions,82conversion_value, plus any extra the user reports on. Keep the platform's own conversion column83name in the notes so a report can name it.8485## Metric formulas (the only ones used anywhere)86- CTR is clicks divided by impressions.87- CPC is spend divided by clicks.88- CPM is spend divided by impressions, times 1,000.89- Conversions come from the platform's own conversion column, with its name kept.90- CPA is spend divided by conversions.91- ROAS is conversion value divided by spend.92- A metric whose denominator is zero or whose input is absent is written "not available", never93 zero and never estimated.94- Never add one platform's attributed conversions to another platform's unless the user confirmed95 the attribution windows match. When they have not, report per platform and say why there is no96 total.9798## Output99The counts line in chat: platforms read live, files read, rows kept, rows dropped, duplicates100dropped, date range per platform, and anything that needs the user. Then the check file path.101Nothing else.102103## Never104Edit an export in place. Write a number into the ledger that came from neither a live view nor an105export. Convert currency. Carry a previous period's figure forward as new. Report a period the106data does not cover. Change anything inside a platform while reading it.