AI-Powered Performance MarketingAttribution, incrementality and mix modeling · Lesson 12 of 15

Marketing mix modeling with Meridian and Robyn

Article · 8 min · 8 min lecture

Video lecture

Marketing mix modeling with Meridian and Robyn

13 chapters · about 8 min · full transcript

Coming soon

Chapter 1 of 13

Marketing mix modeling

  • What MMM does and doesn't
  • Meridian vs Robyn
  • Data you need
  • A Meridian walkthrough

The narrated lecture is in production

Every chapter is scripted and ready. Browse the chapters and read the full transcript now — the video will appear here when it’s published.

Chapters

What MMM is — and is not

A marketing mix model (MMM) is a statistical model that explains an outcome (sales, conversions, sign-ups) over time as a function of marketing spend or exposure by channel, plus non-marketing factors: seasonality, price, promotions, distribution, competitor activity, macro factors. It uses aggregated data (weekly by region or national), not user-level tracking, which makes it robust to cookie loss and consent gaps.

MMM answers: roughly how much did each channel contribute, where are we on each channel's response curve, and how should we split next quarter's budget? It does not optimize daily bids or tell you which ad won.

Two leading open-source options

Meridian (Google)Robyn (Meta)
LanguagePythonR (Python port in beta)
ApproachBayesian, hierarchical geo-level modelingRidge regression with multi-objective hyperparameter optimization
Priors / calibrationROI priors, can incorporate experiment results as priorsCalibration with lift test results
Special featuresReach and frequency inputs, geo hierarchy, budget optimizerAutomated model selection, budget allocator
AvailabilityGenerally available since 2025; open sourceActively maintained open source

Both need good data and judgment. Neither is "plug and play."

Data you need

  • Outcome: weekly (or daily) sales or conversions, ideally by region, for 2–3 years where possible (Google's Meridian guidance discusses data sufficiency; more history and more geos help).
  • Media: spend and, where possible, impressions or reach per channel per period.
  • Controls: price, promotions, holidays (Ramadan and Eid shift each year — encode them by actual dates), product launches, stock-outs, organic search trends, macro indicators.
  • Population per geo for geo-level models.

Key concepts inside the model

  • Adstock (carryover): advertising effects decay over time; TV and YouTube effects linger longer than search.
  • Saturation: response curves (see the budget lesson).
  • Priors (Bayesian): what you believe before seeing data — e.g., "ROI of YouTube is likely between 0.5 and 3". Experiment results make excellent priors.
  • Uncertainty: good MMMs report credible intervals. A channel whose interval spans from harmful to excellent needs an experiment.

Worked example: a Pakistani FMCG brand

A packaged-food brand in Pakistan spends on TV, YouTube, Meta, TikTok, influencers and trade promotions. They build a Meridian model with weekly sales by province for three years, TV GRPs, digital spend and impressions, promotions, price index and Ramadan/Eid dates. Findings (illustrative): TV and YouTube have long carryover; Meta and TikTok show strong short-term effects with saturation at current spend in Punjab but headroom in Sindh; influencer spend has a wide interval. Actions: shift some digital budget toward Sindh, run a geo test on influencer spend to narrow the interval, and re-run the model quarterly with the test as a prior.

Hands-on: the Meridian workflow (Python)

The structure below follows Meridian's getting-started pattern. Class and argument names evolve between releases — check the current Meridian documentation before running.

# pip install --upgrade google-meridian
import tensorflow_probability as tfp
from meridian import constants
from meridian.data import load
from meridian.model import model, spec, prior_distribution
from meridian.analysis import optimizer

coord_to_columns = load.CoordToColumns(
    time="week", geo="province", population="population",
    kpi="orders", revenue_per_kpi="avg_order_value",
    controls=["price_index", "promo_flag", "ramadan_flag"],
    media=["tv_grps", "youtube_imps", "meta_imps", "tiktok_imps"],
    media_spend=["tv_spend", "youtube_spend", "meta_spend", "tiktok_spend"],
)
loader = load.CsvDataLoader(
    csv_path="mmm_weekly_by_province.csv", kpi_type="non_revenue",
    coord_to_columns=coord_to_columns,
    media_to_channel={"tv_grps": "TV", "youtube_imps": "YouTube", "meta_imps": "Meta", "tiktok_imps": "TikTok"},
    media_spend_to_channel={"tv_spend": "TV", "youtube_spend": "YouTube", "meta_spend": "Meta", "tiktok_spend": "TikTok"},
)
data = loader.load()

prior = prior_distribution.PriorDistribution(
    roi_m=tfp.distributions.LogNormal(0.2, 0.9, name=constants.ROI_M))
mmm = model.Meridian(input_data=data, model_spec=spec.ModelSpec(prior=prior))
mmm.sample_prior(500)
mmm.sample_posterior(n_chains=4, n_adapt=500, n_burnin=500, n_keep=1000)

opt = optimizer.BudgetOptimizer(mmm)
results = opt.optimize()  # review the suggested reallocation and its uncertainty

Check convergence diagnostics (for example R-hat) and model fit before trusting outputs.

Using AI to help

LLMs are useful for: drafting data dictionaries, writing data-cleaning code, explaining diagnostics, and turning model output into a plain-language memo. They are not a substitute for the model. Never paste confidential sales data into tools your organization has not approved.

Pitfalls

  • Too little variation: if you spent the same every week, the model cannot learn a response.
  • Collinearity: channels that always move together cannot be separated — run experiments to break the link.
  • Ignoring uncertainty and presenting point estimates as facts.
  • Treating MMM as a one-off project instead of a quarterly process.

How to measure success

Out-of-sample fit, stable results across refreshes, agreement with experiments (calibration), and — above all — budget decisions that improve total business outcomes when tested.

Key takeaways

  • MMM explains outcomes with aggregated data by channel and controls — robust to tracking loss, but not a daily tool.
  • Meridian (Google, Bayesian, Python) and Robyn (Meta, R) are the leading open-source options.
  • You need 2–3 years of weekly data, spend variation and good controls (including moving holidays like Ramadan).
  • Adstock, saturation, priors and uncertainty intervals are the core concepts.
  • Calibrate with experiments and refresh quarterly.

Check your understanding

Quick questions to lock in the lesson. They don’t count towards your certificate.

  1. Why is MMM resilient to cookie loss and consent refusals?
  2. Two channels always had budgets increased and decreased together. What problem does this create for MMM?
  3. What is the best use of a recent geo test result in a Bayesian MMM like Meridian?

Put it into practice

List the data you would need for an MMM of your business: outcome, media, controls and geos. Mark which you have for 2+ years and where you lack spend variation.

Enrol for free to save your progress

Reading is always free. Enrol to keep your place, take the final assessment and earn a verifiable certificate.