Back to recipes
Campaign PlanningAdvancedClaude Code

Marketing Budget Reallocation Optimizer

Adam Weinroth

By Adam Weinroth

Every quarter, your marketing team debates where to shift budget — but the decisions are driven by gut feel instead of data. You have channel performance data scattered across platforms, and building a proper budget optimization model in a spreadsheet would take your ops team a week. You need to quickly analyze spend vs. performance across all channels and generate data-backed reallocation recommendations.

Estimated Time Savings

8 hours

saved per use

Why this tool?

Claude Code can write and execute Python scripts that process your data, build optimization models, and generate professional visualizations — all in one conversation. No need to context-switch between an AI chat and a coding environment.

Step-by-step workflow

  1. 01

    Export last quarter's spend and performance data from each marketing channel (Google Ads, Meta, LinkedIn, email, content, events, etc.) into a single CSV with columns for channel, spend, leads, opportunities, revenue, and conversion rates.

  2. 02

    Ask Claude Code to write a Python script that calculates CAC, ROI, and cost-per-opportunity for each channel, then visualizes performance in a scatter plot.

  3. 03

    Have Claude Code build a budget optimization model that simulates different allocation scenarios based on diminishing returns curves for each channel.

  4. 04

    Run the script to generate a recommended reallocation plan with projected impact on pipeline and revenue.

  5. 05

    Export the charts and recommendation summary as a presentation-ready report for your CFO or VP of Marketing.

Example prompts

Prompt 1
I have a CSV with our Q4 marketing spend and performance data across 8 channels. Columns: channel, spend, impressions, clicks, leads, MQLs, opportunities, closed_won_revenue. Please write a Python script that: (1) Calculates CAC, ROAS, cost-per-lead, cost-per-opportunity, and lead-to-close rate for each channel, (2) Creates visualizations: a quadrant scatter plot (CAC vs. volume), a waterfall chart of current vs. recommended budget, and a channel efficiency ranking, (3) Builds a simple optimization model that reallocates our total budget to maximize projected pipeline, assuming diminishing returns, (4) Outputs a summary table showing current spend, recommended spend, delta, and projected impact for each channel.

What to expect

A working Python script that processes your channel data and produces: (1) Performance metrics table with CAC, ROAS, and conversion rates per channel, (2) Three publication-quality charts — efficiency quadrant, budget waterfall, and channel ranking, (3) An optimized budget allocation table showing where to increase and decrease spend, with projected pipeline lift. The script runs locally on your data and can be re-used each quarter.