Tools · Media Mix Modeling

Media Mix Modeling Tool

The Media Mix Modeling tool is a Bayesian MMM application I built in Python on PyMC. It estimates how much revenue (or how many leads) each marketing channel actually drives, reports it with credible intervals instead of false precision, and turns the result into response curves, budget allocations, and what-if scenarios. It’s used on client engagements, not sold as a product.

Book a Discovery Call

Media Mix Modeling tool attribution view: a Revenue Attribution by Channel waterfall from a $15,378,868 baseline through Organic Search ($9,342,146), Paid Search ($4,302,179), Paid Social, Video, Display, Affiliate, and Email ($345,566) to the total, and a revenue share donut chart totaling $33,014,092 with Organic Search at 28.3% and Paid Search at 13.0%.
Channel attribution on the tool’s synthetic sample data (104 weeks, five paid channels plus organic search and email). Organic Search is the biggest contributor after baseline demand.

Why Build a Custom Media Mix Model?

Click-based attribution in GA4 undervalues anything that influences a purchase without getting the last click. Paid social, display, video, and SEO all look worse than they are, and branded paid search looks better than it is. Media mix modeling (MMM) gets around that by measuring the relationship between spend and revenue over time, with no cookies or tagging involved. I covered the case for it in Can Media Mix Modeling Be Used for Measuring SEO Value?

Google Meridian and Meta’s Robyn are both excellent open-source MMM libraries. The fact is that both are code libraries, and the person defending a marketing budget to a CFO is rarely the person who wants to tune a sampler in a notebook. I built this tool on the same principles as Meridian (Bayesian regression, adstock, saturation, credible intervals) rather than on top of it, with a UI that takes a CSV in and puts decisions out.

The other reason is SEO. Most MMMs treat organic search as noise in the baseline. This model lets organic sessions, email sessions, or content output sit in the model as control variables and show up in the attribution, which is the only way I’ve found to put a defensible number on SEO’s contribution next to paid media.

What Data Does a Media Mix Model Need?

One CSV, one row per week (or per day). The validator checks it before any modeling happens.

InputWhat it needsNotes
DateWeekly or daily periods, no duplicates.52 periods minimum. 104 (two years) is the realistic floor for separating seasonality from media effects.
KPIRevenue or leads.ROI is reported as revenue per dollar or leads per dollar to match.
Media spendOne column per channel.Paid search, paid social, display, video, affiliate, email, TV, radio, out-of-home, direct mail, or anything else with a spend line.
ControlsAnything else that moves the KPI.SEO sessions, promotions, pricing, macro events. Each gets an expected direction (positive, negative, unknown) and a prior strength.

Validation flags the usual problems before they become bad estimates: duplicate or unparseable dates, negative spend, channels that are all zeros, too many missing values, and spend columns that are highly correlated with a control variable (the classic multicollinearity trap where two channels always move together and the model can’t tell them apart).

Control Variable Configuration panel listing five control variables (Seo Sessions, Email Sessions, Content Value Index, Technical Seo Score, Backlink Authority), each with expected effect Positive and prior strength Weak, with Show in Attribution checked for Seo Sessions and Email Sessions.
Control variable setup. Organic search and email sessions are marked to show in attribution; the SEO activity metrics stay as controls.

How Does the Media Mix Model Work?

The model is a Bayesian regression that explains each period’s KPI as baseline demand plus the transformed effect of every media channel. Five pieces do the work.

1. Adstock: Media Spend Has a Memory

Advertising keeps working after the week it runs. Geometric adstock carries a share of each week’s spend into the following weeks, with a decay rate and maximum lag per channel. TV and video carry over for weeks. Paid search and affiliate barely carry over at all. Each channel type starts from a sensible preset that the analyst can adjust.

2. Saturation: Diminishing Returns on Media Spend

The tenth thousand dollars in a channel doesn’t buy what the first thousand did. A Hill saturation curve bends each channel’s response, and the half-saturation point (where the channel is delivering half its maximum effect) is learned from the data rather than assumed.

3. Baseline: Sales That Would Have Happened Anyway

Intercept, linear trend, Fourier seasonality terms, and the control variables together model the revenue that shows up regardless of media. Getting the baseline right matters more than anything else. An underfit baseline hands seasonal demand to whichever channel happened to spend during peak season.

4. Bayesian Priors: What We Believe Before Seeing the Data

Media effects are constrained to be non-negative, since a channel can be useless but it shouldn’t mathematically destroy revenue. Control variables get priors that match their expected direction and strength. Priors are scaled to the KPI so the same configuration works for a business doing $40K a week or $4M.

5. Fit, Validate, and Diagnose the Model

PyMC samples the posterior with NUTS across multiple chains. The most recent weeks are held out so the model gets judged on data it never saw, with R² on the training window and MAPE on the holdout. Convergence diagnostics (R-hat and effective sample size from ArviZ) have to pass before any of the numbers get trusted. A model that hasn’t converged produces confident-looking garbage.

Model Fit chart with R-squared of 0.922, plotting actual weekly revenue as a solid line against predicted revenue as a dashed line from December 2024 to November 2026.
Actual vs. predicted weekly revenue. R² of 0.922 on the sample data.
Model diagnostics tiles showing maximum R-hat of 1.010 labeled Converged, minimum effective sample size of 870 labeled Sufficient, and method Bayesian MCMC.
Convergence diagnostics. If R-hat and effective sample size don’t pass, nothing else on the results page gets used.

What Does the Model Report?

Channel contribution and ROI with credible intervals

Every channel’s contribution and ROI is computed across the full posterior, then reported as a mean with a 95% credible interval. A channel with an ROI of 2.4 and an interval of 1.9 to 2.9 is a different conversation than one at 2.4 with an interval of 0.3 to 4.8. The width of the interval is the most honest thing an MMM can tell you.

Return on Investment by Channel bar chart with 95% credible interval error bars and a break-even line at 1.0x: Paid Search 1.41x, Affiliate 1.26x, Video 0.73x, Paid Social 0.63x, Display 0.41x, above an ROI details table with spend, revenue, ROI credible intervals, marginal ROI, and status per channel.
ROI by paid channel with 95% credible intervals. Note how wide they are on the sample data: Paid Search runs from 0.64x to 2.18x. That width is the model being honest about what the data can and can’t tell you.

Organic search and email in the attribution

Organic search sessions and email sessions sit in the model as control variables marked for attribution, so they show up in the waterfall next to the paid channels instead of disappearing into the baseline. On the tool’s synthetic sample data, Organic Search accounts for $9.3M (28% of revenue), more than any paid channel. A separate SEO Performance view goes a level deeper, adding the lagged effects of content output, technical SEO improvements, and link building on top of organic traffic.

SEO Performance tab showing total SEO revenue of $11,326,487, a 26.5% SEO share of revenue, and average weekly SEO revenue of $108,909, with a category breakdown of Organic Traffic $9,687,712, Technical SEO $609,452, Link Building $572,343, and Content $456,980, a pie chart of SEO revenue by category, and SEO insights on lag effects.
The SEO Performance view. Its total is higher than the Organic Search bar above because it adds the lagged effects of content, technical SEO, and link building to organic traffic.

Marginal ROI by channel

Average ROI says how a channel performed. Marginal ROI says what the next dollar is worth at current spend. A channel can have a great average and a poor margin when it’s already deep into saturation, and that’s exactly where budget gets wasted. The tool turns the two numbers into a plain recommendation per channel: scale up, cut, optimize, or reallocate.

Channel response curves

Each channel’s spend-to-revenue curve, plotted from zero to well past the highest spend level in the data. These are the charts that end up in the CFO deck because they make diminishing returns obvious without any statistics.

Response Curves chart plotting incremental revenue against weekly spend for Paid Search, Paid Social, Display, Video, and Affiliate, with Paid Search rising highest to about $77,000 and Paid Social flattening near $26,000.
Response curves for the five paid channels. Paid Search keeps climbing while the others flatten out early.

Media budget optimizer

Given a total budget (current or new), a constrained optimizer (SciPy SLSQP) finds the channel split that maximizes total response. Per-channel minimums and maximums keep the answer realistic, because nobody is going to cut TV to zero or triple paid social in a quarter regardless of what the math says. It also scans budget levels to find where the marginal return on total spend drops below break-even.

Budget optimizer results: expected lift of $6,129 (+6.4%) at the same $105,676 weekly budget, a current vs. optimal allocation bar chart, and a recommended changes table moving budget into Paid Search (+64.4%) and Affiliate (+25.2%) and out of Display (-63.9%), Video (-33.5%), and Paid Social (-30.2%).
Same budget, different split. On the sample data the optimizer finds a 6.4% revenue lift by moving spend out of Display, Video, and Paid Social into Paid Search and Affiliate.

Media budget scenario planning

What-if sliders for each channel, quick scenarios like “all channels +10%”, and single-channel sensitivity sweeps. Useful for the questions that come up in planning meetings before anyone has decided on a budget.

Scenario comparison table of five standard scenarios from +20% Paid Search (+$5,041, +2.1%) to Decrease All 10% (-$4,986, -2.0%), with a revenue impact by scenario bar chart.
Standard what-if scenarios, ranked by revenue impact.

Incrementality testing toolkit

MMM is a model, and models should be checked against experiments. The toolkit covers geo-lift analysis with a synthetic control, holdout test evaluation against what the model predicted, and power analysis so a test is sized to detect the effect before it runs. When a lift test and the MMM disagree, the experiment wins.

What Can’t Media Mix Modeling Tell You?

When Does Media Mix Modeling Make Sense?

Working With Me on Media Mix Modeling

The Media Mix Modeling tool runs on client engagements as part of my consulting work. Most of the effort is upstream of the model: pulling spend from ad platforms, reconciling it with revenue, deciding which controls belong in the model, and then explaining the output to people who don’t want to hear about posterior distributions. If you want to know what your channels are actually doing, feel free to reach out.

← All Tools