Apple Ads Advanced Sync
Overview
99.8% match with bank payout
Implementation
- Core sync logic:
src/lib/server/apple-ads-advanced-sync.ts - API endpoints:
src/routes/api/sync/apple-ads-advanced/
More details
Primary source: Apple Ads Campaign Reports API (DAILY granularity)
- Accurate: 99.8% match with bank payment
- Available in real-time (partial data for today), and only the last 90 days
- Dates input for fetch: dates interval
- When data becomes available, how many days may the source adjust them: 14days (Claude told me, conservative)
Secondary source: Apple Ads Campaign Reports API (WEEKLY granularity)
- Accurate: 99.8% match with bank payment
- but daily accuracy lost, because we evenly spread the weekly cost through days
- Available only the last 24 months
- Also it can slighlty drop the accuraccy in the merging point of these 2 reports.
- Dates input for fetch: dates interval
- When data becomes available, how many days may the source adjust them: 14days (Claude told me, conservative)
How sync works
<!-- The sync can be triggered any time. So it needs to be idempotent,
can handle situations when it's wasn't run for a long period of time,
and also don't do anything if already ran today.
The fetching function will write the data to DB, and immediately update
the lastSyncDate if got higher value. So if it sucessfuly saved data for 12 december, and
the lastSyncDate is currently 8 december it would udpate it to 12 december.
Note the date ranges are always inclusive. -->
if ( lastSyncDate < today ):
fetchData ( range: {start: (lastSyncDate + 1day) - 14days, end: today} ):
if( range.start < today - 90days ):
fetchDataDailyGranularity ( range: { start: today - 90days, end: range.end } )
fetchDataWeeklyGranularity ( range: { start: range.start, end: today - 90days - 1day } )
else:
fetchDataDailyGranularity ( range: range )
How the accuracy was measured + ground truth data for testing
- Apple Ads Advanced cost - 3. feb 2025 - 30. Nov 2025 (UTC) (intentionally aligned to weeks)
- payment from bank account - 19402 € (apple invoiced us advanced + basic together for 21996 €, so I just proportionally scaled to get cost of Basic ads)
- reported by this finboard - 19355 €