Skip to content
Run this on autopilot — free
Workflow · Audits

Reconcile your Meta and Google Ads spend against budget, automatically

Time to first output: ~15 minutes one-time setup (GoMarble + Claude Code), then a few minutes each time you run the script

What it does?

A Python script pulls month-to-date spend from Meta and Google via GoMarble MCP and reconciles it into one view — flagging budget variance, run rate, and the Meta/Google split before month-end.

What you need

  • Meta ad account ID (act_...) and/or Google Ads customer ID
  • Optional: monthly budget targets for Meta and/or Google (--meta-budget, --google-budget)
  • GoMarble API key
  • Anthropic API key

First, connect Claude Code to your ad accounts

Set up GoMarble MCP once, then paste the build prompt below into Claude Code.

1

Install Claude Code and Python

Download Claude Code and Python if you don't already have them installed.

2

Connect your ad accounts on GoMarble

Go to apps.gomarble.ai, sign up, and connect your Meta Ads and/or Google Ads account in the Integrations page.

3

Get your GoMarble API key

In GoMarble, go to Settings → API Key, copy it, and save it somewhere safe.

4

Add GoMarble MCP to Claude Code

Run the command below in your terminal to connect Claude Code to your GoMarble MCP server.

claude mcp add --transport http gomarble https://apps.gomarble.ai/mcp-api/mcp --header "Authorization: Bearer <paste your API key>"

Claude Pro or Max is recommended for higher usage limits.

The script

Paste this into Claude Code — it will write the Python CLI script for you, based on this spec.

Lead-magnet prompt · free

Build a Python CLI script called spend_reconciliation.py that reconciles spend across Meta and Google Ads using GoMarble MCP.

CLI args: --meta act_123456 and/or --google 1234567890, --meta-budget 50000 (optional), --google-budget 30000 (optional)

Use GoMarble MCP call pattern:

ANTHROPIC_API_KEY = ""
GOMARBLE_API_KEY = ""

POST https://api.anthropic.com/v1/messages, anthropic-version: "2023-06-01", anthropic-beta: "mcp-client-2025-04-04"

mcp_servers: [{type: "url", url: "https://apps.gomarble.ai/mcp-api/sse", name: "gomarble", authorization_token: GOMARBLE_API_KEY}]

6-step pipeline:

1. Account Info — fetch from both platforms

2. Daily Spend (this month) — Meta: facebook_get_adaccount_insights, date_preset: this_month, time_increment: 1, account level. Google: GAQL daily account spend

3. Campaign-Level Spend — Meta: campaign level, this_month. Google: GAQL campaign spend this month

4. Compute — MTD vs budget variance, daily run rate, projected month-end, cross-platform split (Meta % vs Google %), per-campaign contribution

5. AI Brief — rebalancing recommendations

6. Output: reconciliation.csv, reconciliation_brief.txt

What you get back

  • Format: Running the generated script (e.g. `python spend_reconciliation.py --meta act_123456 --google 1234567890 --meta-budget 50000 --google-budget 30000`) writes two files:
    • reconciliation.csv — daily/campaign-level spend rows
    • reconciliation_brief.txt — an AI-written brief covering MTD-vs-budget variance, daily run rate, projected month-end spend, and the Meta% vs Google% split
Upgrade

Want this automated?

Run the prompt above every Monday morning automatically. GoMarble Agents don't just deliver the report (Slack / email / in-app) — they can execute the recommended changes directly in your ad account, too. Offload the whole recurring task and stop doing it manually.

Try GoMarble Agents free →

FAQ

Does this script work if I only advertise on one platform?
Yes — pass either --meta or --google alone (or both); the pipeline skips whichever platform you don't provide.
What data does it pull?
Daily and campaign-level spend for the current month from Meta (via facebook_get_adaccount_insights) and/or Google Ads (via a GAQL query run through google_ads_run_gaql).
Do I need to know Python to use this?
No — you paste the build spec into Claude Code, which writes spend_reconciliation.py for you; you just run it with your account IDs.
What's in the output files?
reconciliation.csv has the raw daily/campaign spend rows, and reconciliation_brief.txt is an AI-generated brief covering budget variance, run rate, and rebalancing recommendations.
Are the budget targets required?
No — --meta-budget and --google-budget are optional; without them the script still reports MTD spend and the cross-platform split, just without a variance-to-target calculation.
Does it modify my campaigns?
No, this script only reads data and writes local report files — it doesn't make any changes to your ad accounts.

Skip the prompt — let GoMarble do this for you.

Sign up, connect your ad accounts, and cross-channel spend reconciliation runs on every account, every week, automatically.