algo-ad-budget
Optimize advertising budget allocation across campaigns using marginal returns analysis. Use this skill when the user needs to distribute budget across multiple campaigns, optimize spend pacing, or maximize overall ROAS under budget constraints — even if they say 'how to split my ad budget', 'campaign budget optimization', or 'diminishing returns on ad spend'.
git clone --depth 1 https://github.com/asgard-ai-platform/skills /tmp/algo-ad-budget && cp -r /tmp/algo-ad-budget/algo-ad-budget ~/.claude/skills/algo-ad-budgetSKILL.md
# Ad Budget Allocation Optimization
## Overview
Budget allocation distributes a total advertising budget across campaigns to maximize overall returns. Uses the equal marginal returns principle: allocate until the marginal CPA (or marginal ROAS) is equalized across all campaigns. Handles diminishing returns and budget constraints.
## When to Use
**Trigger conditions:**
- Distributing a fixed budget across multiple campaigns or channels
- Identifying diminishing returns and optimal spend levels per campaign
- Rebalancing budget after performance changes
**When NOT to use:**
- When optimizing bids within a single campaign (use bidding strategy)
- When there's only one campaign (nothing to allocate across)
## Algorithm
```
IRON LAW: Equal Marginal Returns Principle
Optimal allocation makes the MARGINAL return of the last dollar
equal across ALL campaigns. If Campaign A's marginal CPA is $5
and Campaign B's is $15, shift budget from B to A until they equalize.
Total budget constraint: Σ budget_i = total_budget.
```
### Phase 1: Input Validation
Collect per-campaign: historical spend, conversions, revenue at multiple spend levels. Need at least 3 data points per campaign to fit response curve.
**Gate:** Sufficient historical data to estimate response curves.
### Phase 2: Core Algorithm
1. Fit response curve per campaign: conversions = f(spend). Common models: log curve, power curve, or S-curve
2. Compute marginal return curve: f'(spend) for each campaign
3. Allocate: use Lagrangian optimization or iterative greedy — assign next marginal dollar to campaign with highest marginal return
4. Apply constraints: minimum spend floors, maximum caps, channel-specific rules
### Phase 3: Verification
Check: total allocation = total budget, no campaign below floor or above cap, marginal returns approximately equal at boundaries.
**Gate:** Allocation sums to budget, constraints satisfied.
### Phase 4: Output
Return allocation table with expected performance projections.
## Output Format
```json
{
"allocation": [{"campaign": "Search-Brand", "budget": 50000, "expected_conversions": 200, "expected_cpa": 250}],
"total": {"budget": 200000, "expected_conversions": 650, "blended_cpa": 308},
"metadata": {"optimization_method": "lagrangian", "response_model": "log_curve"}
}
```
## Examples
### Sample I/O
**Input:** Budget: $100K, Campaigns: Search ($50K, 100 conv), Social ($30K, 60 conv), Display ($20K, 20 conv)
**Expected:** Shift budget from Display (high marginal CPA) to Search (low marginal CPA). e.g., Search $60K, Social $30K, Display $10K.
### Edge Cases
| Input | Expected | Why |
|-------|----------|-----|
| One campaign dominates | Most budget to winner | But maintain minimum floor for others |
| All campaigns saturated | Reduce total spend | Spending more won't help |
| New campaign, no data | Use minimum test budget | Need data before optimizing |
## Gotchas
- **Response curve extrapolation**: Don't optimize beyond observed spend ranges. The curve may change shape at higher spend levels.
- **Attribution overlap**: Users may see ads across campaigns. Last-click attribution double-counts, inflating high-funnel campaign CPA. Use multi-touch attribution.
- **Diminishing returns assumption**: Not all campaigns follow smooth diminishing returns. Some have step functions (e.g., reaching a new audience segment at a spend threshold).
- **Time dynamics**: Response curves shift seasonally and competitively. Refit curves monthly or use rolling windows.
- **Minimum viable spend**: Each campaign needs enough budget to exit the learning phase. Spreading too thin means no campaign gets sufficient data.
## References
- For response curve fitting methods, see `references/response-curves.md`
- For multi-touch attribution integration, see `references/attribution-integration.md`Implement and select ad bidding strategies from manual CPC to automated target-CPA and target-ROAS. Use this skill when the user needs to choose a bidding strategy, set up automated bidding, or optimize bid parameters — even if they say 'what bidding strategy should I use', 'target CPA setup', or 'smart bidding configuration'.
Build CTR prediction models for estimating ad click-through rates from features. Use this skill when the user needs to predict click probability, build an ad ranking model, or evaluate ad creative performance — even if they say 'predict click rate', 'ad relevance scoring', or 'which ad will get more clicks'.
Implement Generalized Second Price auction for ad slot allocation and pricing. Use this skill when the user needs to understand search ad auctions, compute ad positions and costs-per-click, or analyze bidding dynamics — even if they say 'how does Google Ads auction work', 'ad rank calculation', or 'second price auction for ads'.
Implement VCG mechanism for incentive-compatible ad slot allocation with truthful bidding. Use this skill when the user needs to design a truthful auction mechanism, compute externality-based payments, or understand why platforms may prefer GSP over VCG — even if they say 'truthful auction design', 'VCG payments', or 'incentive-compatible mechanism'.
Explain blockchain fundamentals including distributed ledger architecture, consensus mechanisms, and block structure. Use this skill when the user needs to understand blockchain concepts, evaluate whether blockchain fits a use case, or design a blockchain-based solution — even if they say 'how does blockchain work', 'do I need blockchain', or 'distributed ledger'.
Design and implement smart contracts as self-executing programmatic agreements on blockchain. Use this skill when the user needs to build automated on-chain logic, evaluate smart contract security, or design tokenized business rules — even if they say 'smart contract development', 'automated agreement', or 'on-chain logic'.
Implement BM25 ranking function for e-commerce product search relevance scoring. Use this skill when the user needs to build a text-based product search engine, improve search result relevance, or replace basic TF-IDF with a more robust ranking function — even if they say 'product search ranking', 'search relevance', or 'BM25 implementation'.
Design multi-objective e-commerce product ranking combining relevance, conversion, and business metrics. Use this skill when the user needs to build a product ranking system beyond text relevance, balance relevance with commercial objectives, or implement learning-to-rank — even if they say 'product sorting', 'search result ranking', or 'how to rank products'.