← Back
Home › Systems › Sales, marketing and customer service

marketing-measurement

How a marketing team combines mix modelling, geo experiments and attribution to learn which spend caused sales, and to split a budget across channels.

Google Meridian, Measured, Rockerbox, Haus

Open the marketing-measurement pagemarketing-measurement Generalized linear models(GLMs)machine-learning: Linear model for counts, rates, positive amounts and proportions: a linear score pushed through a link, fitted by iteratively reweighted least squares.›Shapley values treeshapmachine-learning: TreeSHAP and Shapley attributions for per-prediction explanations and reason codesHamiltonian monte carlo nutsnumerics: HMC with leapfrog integration and the No-U-Turn sampler; step size and mass-matrix adaptationMarkov chain monte carlonumerics: Metropolis-Hastings and Gibbs sampling: proposals, burn-in, thinning, convergenceVariational inferencenumerics: ADVI and mean-field VI: optimize the ELBO with reparameterization gradientsQuadratic programmingoptimization: Convex QP solvers (active-set, interior-point, ADMM) for constrained optimizationPrivate set intersectionsecurity: Compute the overlap of two parties' sets without revealing the rest (ECDH-PSI, OPRF)Adstock saturation transformsstatistics: Carry-over (adstock) and diminishing-returns (saturation) transforms of spend before regression in mix modelsBootstrap confidence intervalsstatistics: Resampling-based confidence intervals for arbitrary statisticsCUPED (variance reduction withpre-experiment covariates)statistics: Subtract the part of each unit's outcome that a pre-experiment covariate predicts; the effect estimate stays unbiased and its variance shrinks by 1 - rho^2.›Difference in differencesstatistics: Causal effect estimation from treated/control group pre/post changesHypothesis testingstatistics: Pick a test statistic, compare it to its distribution under "no effect", read off a p-value, and control error rates across one test or many.›Sequential hypothesis testingstatistics: Group-sequential and alpha-spending designs for interim analyses without inflating errorSynthetic controlstatistics: Construct a weighted control from donor units to estimate an intervention effectTime-series forecasting(baselines, model families, ba…statistics: The end-to-end recipe: fix horizon and uncertainty, beat naive baselines, choose a model family, and validate with rolling-origin backtests and scale-free metrics.›Touchpoint attributionstatistics: Assigning conversions to ad touches: last-click, multi-touch, data-driven models, attribution windowsIdentity resolutionstorage: Merge anonymous and known identifiers into one profile (union-find over identity edges)Sessionizationstorage: Group events into sessions by inactivity gapsLinear and logistic regressionmachine-learning: Fit a weighted sum of features to a number (least squares) or a probability (logistic); the baseline every model must beat.›Newton root findingnumerics: Linearize at the guess and jump to the tangent root; quadratic convergence near a simple root, made robust by brackets (1D) or line search.›Gradient-boosted decision trees(GBDT)machine-learning: Add small regression trees one at a time, each fitted to the loss gradient; histogram splits over 256 bins make it the strongest tabular default.›Verlet / leapfrognumerics: Half-kick, drift, half-kick: a second-order, time-reversible, symplectic integrator with one force evaluation per step whose energy error stays bounded for millions of steps.›LU and Cholesky factorizationnumerics: Factor A = PLU (any square matrix, partial pivoting) or A = LLᵀ (SPD) once in O(n³), then solve each right-hand side in O(n²).›Mcmc convergence diagnosticsnumerics: R-hat, effective sample size and divergence checks for MCMC runsMonte Carlo integrationnumerics: Estimate an expectation by averaging random samples; error falls as σ/√N in any dimension, and variance reduction (antithetic, control variates, importance sampling) shrinks σ.›PRNGs (PCG, xoshiro)numerics: Small, fast, statistically strong non-cryptographic generators: PCG32 and xoshiro256**, with seeding, parallel streams and unbiased ranges.›Reverse-mode automaticdifferentiationml-training: Record the forward computation on a tape, then sweep it backwards once to get the gradient of a scalar loss for all inputs.›Constrained parametertransformsnumerics: Map constrained parameters to unconstrained space (log, logit, simplex, Cholesky) with Jacobian correctionsAdamWml-training: Adam's per-parameter adaptive steps with weight decay applied directly to the weights; the default optimizer for transformers and LLM pretraining.›Sparse matrices (CSR)numerics: Compressed sparse row stores only nonzeros as row pointers, column indices and values; SpMV streams them once, so it is memory-bandwidth bound.›+ 16 moreL-BFGSnumerics: Quasi-Newton minimizer that approximates the inverse Hessian from the last m gradient differences via the two-loop recursion; O(m·n) memory and work per step.›Loss functionsmachine-learning: The scalar a model minimizes: cross-entropy for classes and tokens, MSE or Huber for values, each with a stable form and simple gradient.›Quantile sketchesdata-structures: Mergeable quantile sketches: t-digest, DDSketch, HDR histogramsRegularizationmachine-learning: Techniques that trade training fit for generalization: weight decay, dropout, early stopping, label smoothing and data mixing, with the exact update rules and defaults.›Rejection samplingml-training: Best-of-n and filtered sampling: generate many candidates, keep those passing a verifier or reward threshold+ 10 more+ 10 more+ 7 more+ 1 more

How it is built

Architecture overview

A marketing measurement system answers one question: what did each euro of spend cause, as opposed to what merely happened while it was spent? No single method answers it well, so the system runs three estimators of different strength and makes them check each other. A marketing mix model (MMM) fits weekly or daily aggregate sales against spend per channel, with carry-over and diminishing returns, and covers every channel including offline. Incrementality experiments (geo-lift tests, holdouts) create a counterfactual on purpose and give a causal number for one channel at one time. Attribution works from individual touchpoint paths and credits conversions to touches; it is fine-grained and fast, but only correlational. A budget optimiser reads the fitted response curves and proposes a spend split. The one idea that makes it work: experiments are rare and expensive, the model is cheap and always on, so experiment results are fed into the model as priors, and the model is trusted only where it agrees with them. Google Meridian, PyMC-Marketing and Robyn are the open MMM frameworks; CausalImpact and GeoLift cover the experiment side.

Parts:

 ad platforms, CRM, web/app events ──► sessionize ──► identity join ──► touchpoint paths ──► attribution
        │ spend, impressions, price,                  (clean room: PSI)                         │ (fast, correlational)
        │ promotions, weather, macro                                                            ▼
        └──► weekly/daily panel ──► MMM (adstock · saturation · trend · season) ──► posterior ──► response curves
                                        ▲ priors from lift ▲                                       │
 geo/holdout experiments ──► DiD / synthetic control ──► lift ± interval ───────────────────────────┤
                                                                                                    ▼
                                                                 budget optimiser ──► spend plan ──► next flight

How the parts fit together

Event data and identity

Attribution and user-level experiments need paths: for each person, the ordered ad touches and the conversion. Raw events (impressions, clicks, visits) become paths through Sessionization (no page yet), which cuts an event stream into visits by an inactivity gap, and through Identity resolution (no page yet), which links the cookies, device ids and logins of one person. The two sides of a path usually sit in different companies: the publisher has the ad exposure, the advertiser has the purchase. Private set intersection (no page yet) lets them compute the overlap and aggregates over it without handing each other their customer lists. Contract with everything downstream: a path table keyed by a person id, plus daily aggregates by channel and region. The mix model never needs the paths; it needs only the aggregates, which is why it survives cookie loss and privacy rules (Meridian's documentation says as much: MMM uses aggregated data and no user-level information).

Mix model

The model explains a KPI (sales, sign-ups) per period, and per geography where available, as a baseline plus channel contributions. Two transforms turn raw spend into effect. Adstock (adstock-saturation-transforms, no page yet) spreads an impression's effect over following periods, usually with a geometric decay, because an ad seen today still works next week. Saturation bends the response so that the tenth million buys less than the first, commonly a Hill-type or logistic curve. Robyn describes exploring adstock rates and saturation curves; PyMC-Marketing lets the user choose among adstock and saturation functions.

The baseline carries what is not marketing: trend, seasonality, holidays, price, promotions. This is the territory of Time-series forecasting, and it matters because a model that misses a seasonal peak credits it to whichever channel was turned up at the time. The regression machinery underneath is a Generalized linear model with a link suited to the KPI (log for revenue-like, positive outcomes), with the transforms as non-linear terms. Why a regression and not a flexible learner: the object of interest is the channel coefficient, with an interval, not the best forecast, and a handful of channels over a few hundred periods cannot support a flexible model. The same collinearity that plagues any regression is severe here, because teams raise all channels together at peak season; the data alone often cannot separate them, which is the case for priors and for experiments.

Bayesian inference engine

With many parameters (a few per channel, plus baseline terms, plus geography effects) and weak data, point estimates are fragile; the Bayesian answer is a posterior, the full range of parameter values the data and the priors support. Sampling it is the job of Markov chain Monte Carlo (no page yet), in practice the No-U-Turn variant of Hamiltonian Monte Carlo (no page yet). Meridian's README states that its model uses NUTS and recommends GPUs because sampling is compute intensive; PyMC-Marketing offers several NUTS implementations (BlackJax, NumPyro, Nutpie). Variational inference (no page yet) is the cheaper alternative: fit a simple distribution to the posterior by optimisation, in seconds instead of minutes, at the price of underestimated uncertainty. Use it for exploration and model search, and NUTS for the numbers that go to the CFO.

Contract with the optimiser: a set of posterior draws, so every downstream number (ROI, marginal ROI, optimum) comes with an interval by simply computing it on each draw.

Incrementality tests

A planned experiment is the only direct causal evidence. Two shapes dominate. A user-level holdout randomises people into exposed and withheld; the analysis is a hypothesis test on a conversion difference, sharpened with CUPED (use pre-period behaviour to remove noise) and, if the team peeks at results while the test runs, with Sequential hypothesis testing (no page yet), because repeated looks inflate false positives. A geo experiment withholds or adds spend in some regions when user-level randomisation is impossible (TV, outdoor, or platforms that cannot hold users out). Google's geo-experiment paper (Vaver and Koehler) describes the design; analysis compares treated regions with control regions over the same weeks with difference-in-differences (no page yet), or builds a weighted blend of control regions that tracks the treated region before the test, synthetic-control (no page yet), and reads the post-period gap as lift. CausalImpact does this with a Bayesian structural time-series model (Brodersen et al.); GeoLift builds on synthetic control methods and includes power calculators for choosing which markets to test. Bootstrap confidence intervals (no page yet) give an interval without distributional assumptions when the lift is a ratio or a custom metric.

Contract with the model: for channel c over a window, a lift estimate and an interval, expressed as incremental outcome per unit of spend. The model takes it as a prior on that channel's ROI; PyMC-Marketing documents lift-test calibration and Meridian lists calibration with experiments as a feature.

Attribution

touchpoint-attribution (no page yet) assigns each conversion's credit across the touches on its path. Rule-based variants (last touch, first touch, linear, time decay) are cheap and biased in known ways. Data-driven variants model the path: Shao and Li's multi-touch attribution models fit conversion probability as a function of the touches, and removal-effect models ask how conversion falls when a channel is deleted from the paths. Credit as a fair split is a cooperative-game question, and Shapley values (no page yet) are the standard answer: a channel's credit is its average marginal contribution over all orders of the other channels, computed exactly for a handful of channels and by sampling or tree-specific algorithms for more. The weakness is built in: paths show who was reached, not who would have bought anyway, so attribution over-credits channels that target likely buyers (search brand terms, retargeting). Use it for fast, within-channel optimisation, such as which creative or keyword, and use the MMM and the experiments to set the level of each channel.

Budget optimiser

Given response curves with posteriors, the optimiser finds the spend split that maximises expected outcome under a total budget and per-channel minimum and maximum. With saturating curves the objective is concave, so a local optimum is the global one. Quadratic programming (no page yet) is the solver family when the response is approximated quadratically around the current spend, or when a variance penalty on the posterior makes the plan risk-averse; general constrained solvers handle the full curves. Robyn describes gradient-based optimisation for budget allocation and PyMC-Marketing ships a budget optimisation module. Contract: the plan is only valid inside the range of spend the model has seen; the optimiser must bound each channel near history, since a saturation curve extrapolated to ten times past spend is a guess.

Data and control flow

One measurement cycle (quarterly, with monthly refreshes):

  1. Pull spend, impressions, prices, promotions and outcomes by channel, region and week; join external drivers such as weather or holidays. Check the panel for gaps and for channels that always move together.
  2. Fit the MMM with weakly informative priors; inspect fit on held-out weeks and the posterior of each channel's ROI. Use variational inference first, NUTS for the final fit.
  3. Compare channels where an experiment exists. A model ROI far outside the experiment's interval means the model is wrong or the world changed; fix the model, do not discard the experiment.
  4. Choose the next experiments where the posterior is widest and the spend is largest. Run them as geo or holdout tests with a power calculation first.
  5. Feed new lift results back as priors, refit, then run the optimiser for the next flight's plan with each channel bounded near its history.

One conversion path (daily, attribution):

  1. Join exposure logs with conversions through the person key (clean room if the data sit with two parties).
  2. Cut the paths with a session gap; drop paths outside the lookback window.
  3. Assign credit by the chosen rule or model, with Shapley-style averaging where a model is used.
  4. Report credit by channel and campaign; compare its channel totals with the MMM to see where they disagree.

Scaling

In the order the limits bite:

  1. Identifiability limits an MMM before compute does: few periods, many correlated channels. Levers: add geographies (a geo-level hierarchical model multiplies the data), add experiments as priors, vary spend on purpose, drop channels that are below noise.
  2. Experiment cost and power: a geo test with few markets or small effects cannot detect a plausible lift. Levers: power calculations before launch, CUPED-style pre-period adjustment, longer tests, pooled tests over several channels.
  3. Sampling time: NUTS on a large geo-level model is hours. Levers: GPU, variational inference for iteration, fewer parameters, refresh the model monthly instead of weekly.
  4. Path data volume: billions of events a day. Levers: sessionize on a stream, keep only paths with a conversion and sampled non-converting paths, compute credit on aggregates.
  5. Privacy: user-level joins shrink. Lever: lean on the aggregate methods and run joins in a clean room.

Failure modes

FailureSymptomCauseFix
Collinear channelshuge, unstable ROI intervals; ROI flips sign between refitschannels move together by season or by planning habitinformative priors, experiments, planned spend variation
Missing driverone channel gets credit for a holiday or a price cutbaseline lacks the true causeadd the driver; compare with a holdout week
Optimiser extrapolatesplan puts several times past spend into one channelsaturation curve not constrained by databound each channel near its observed range
Spillover between geostest lift too small, controls moved tooads reach control regions, or customers travellarger regions, buffer zones, check control stability pre-test
Poor pre-period fitsynthetic control does not track the treated region before the testtoo few or dissimilar donor regions, a short pre-periodmore donors, longer history, check pre-period error first
Peekingfalse wins in experimentsstopping when the interval looks goodpre-set duration, or sequential tests
Attribution over-creditretargeting and brand search look excellent, cut them and sales holdcredit follows exposure to likely buyerscalibrate with holdouts; use incrementality for these channels
Identity driftconversions link to the wrong person or nonecookie churn, shared devicesprobabilistic linking with a confidence, report coverage
Stale modelROI estimates no longer match a fresh experimentcreative, market or competitor changedscheduled refits, an experiment backlog, refit when a test disagrees

Real implementations

namewhat it isrepolicencenotes
MeridianGoogle's Bayesian MMM framework, geo-level, with experiment calibration and reach and frequencygoogle/meridianApache-2.0NUTS sampling, GPU recommended; successor to LightweightMMM
PyMC-MarketingBayesian MMM and customer-lifetime models on PyMCpymc-labs/pymc-marketingApache-2.0adstock and saturation options, lift-test calibration, budget optimisation
RobynMeta's semi-automated MMM: ridge regression, evolutionary hyperparameter searchfacebookexperimental/RobynMITtrend and season decomposition, budget allocation
LightweightMMMearlier Google Bayesian MMMgoogle/lightweight_mmmApache-2.0no longer supported; its README points to Meridian
CausalImpactcounterfactual lift from a Bayesian structural time-series model (R)google/CausalImpactApache-2.0one treated series, several control series
GeoLiftgeo-level lift with synthetic control methods and power calculators (R)facebookincubator/GeoLiftMITmarket selection for geo tests
Private Join and Computetwo-party private set intersection with sums over the matchesgoogle/private-join-and-computeApache-2.0for joins across companies
Measured, Rockerbox, Hauscommercial measurement platformsnoneproprietaryincrementality and attribution services

The alternative: attribution only. It is cheap, needs no model fitting and reports within hours, but it measures exposure, not causation, and degrades as user-level data disappear. Pick it for tactical decisions inside one channel; pick MMM plus experiments when the question is how much to spend on each channel.

Sources

  • Y. Jin, Y. Wang, Y. Sun, D. Chan, J. Koehler, Bayesian Methods for Media Mix Modeling with Carryover and Shape Effects, Google Research, 2017. paper
  • J. Vaver, J. Koehler, Measuring Ad Effectiveness Using Geo Experiments, Google Research, 2011. paper
  • K. Brodersen et al., Inferring causal impact using Bayesian structural time-series models, Annals of Applied Statistics, 2015. DOI 10.1214/14-AOAS788
  • A. Abadie, A. Diamond, J. Hainmueller, Synthetic Control Methods for Comparative Case Studies, Journal of the American Statistical Association, 2010.
  • X. Shao, L. Li, Data-driven multi-touch attribution models, KDD 2011.
  • M. Hoffman, A. Gelman, The No-U-Turn Sampler, JMLR 2014. arXiv:1111.4246
  • S. Lundberg, S.-I. Lee, A Unified Approach to Interpreting Model Predictions, NeurIPS 2017. arXiv:1705.07874
  • Meridian documentation and README; PyMC-Marketing site; Robyn and GeoLift READMEs (repos above).