Shapley Value Attribution
A Cooperative Game Theory Concept Applied to Marketing
The Shapley value originates in cooperative game theory (Lloyd Shapley, 1953) as a method for fairly dividing a payout among players in a coalition, based on each player's average marginal contribution across every possible order in which players could join. Applied to marketing attribution, the 'players' are channels or touchpoints, the 'payout' is the conversion (or revenue), and the Shapley value computes each channel's fair share of credit by averaging its marginal contribution across every possible sub-coalition of channels that could have led to that conversion.
The Formula, in Plain Terms
For a channel i, the Shapley value considers every possible subset S of the other channels, and for each subset asks: 'how much does the conversion outcome change when channel i is added to that subset?' It then averages that marginal contribution across all subsets, weighted by how many subsets of each size exist. Formally:
$$\phi_i = \sum_{S \subseteq N \setminus \{i\}} \frac{|S|!(|N|-|S|-1)!}{|N|!} \left[ v(S \cup \{i\}) - v(S) \right]$$
where v(S) is the conversion value achievable with the subset of channels S, and N is the full set of channels. The key property that makes this fair rather than arbitrary: it's the unique allocation method satisfying efficiency (credit sums to exactly the total conversion value), symmetry (identical channels get identical credit), and additivity across independent games.
Why Marginal Contribution Beats Fixed Weighting
// Simplified Shapley value computation over a small set of channels,
// using empirical conversion rates per subset as the value function v(S).
type ConversionRateMap = Record<string, number>; // key: sorted channel subset, e.g. "google,meta"
function shapleyValues(channels: string[], v: ConversionRateMap): Record<string, number> {
const n = channels.length;
const factorial = (k: number): number => (k <= 1 ? 1 : k * factorial(k - 1));
const result: Record<string, number> = {};
for (const channel of channels) {
const others = channels.filter((c) => c !== channel);
let total = 0;
// Iterate over every subset of "others" (2^(n-1) subsets)
for (let mask = 0; mask < 1 << others.length; mask++) {
const subset = others.filter((_, idx) => mask & (1 << idx));
const withChannel = [...subset, channel].sort().join(",");
const withoutChannel = subset.sort().join(",") || "none";
const vWith = v[withChannel] ?? 0;
const vWithout = v[withoutChannel] ?? 0;
const weight = (factorial(subset.length) * factorial(n - subset.length - 1)) / factorial(n);
total += weight * (vWith - vWithout);
}
result[channel] = total;
}
return result;
}The Combinatorial Explosion Problem
The exact Shapley computation requires evaluating 2^n subsets for n channels — fine for 4-5 channels, computationally infeasible for a realistic marketing stack with 15-20+ channel/campaign combinations, since 2^20 is over a million subsets to evaluate. Production implementations (including Google's DDA) use approximation methods — Monte Carlo sampling of subset orderings, or regression-based approximations that estimate marginal contributions without exhaustive enumeration — trading exact fairness guarantees for computational tractability at scale.
Data Requirements and Sparse-Data Pitfalls
Computing v(S) — the conversion rate or value for each subset of channels — requires enough historical observations of paths containing each subset combination to estimate it reliably. Rare channel combinations (a path through five specific channels that only occurred a handful of times) produce noisy, unreliable v(S) estimates, which then propagate noise into every Shapley value that depends on comparing against that subset. This is the statistical justification behind Google's minimum conversion volume requirement for enabling DDA — below a certain data volume, the underlying v(S) estimates aren't trustworthy enough to compute meaningful marginal contributions.
Shapley Values Still Describe Correlation Within Your Historical Data
What's Next?
Markov chain-based attribution offers a more tractable alternative to full Shapley computation for large channel sets, with its own distinct way of representing channel interactions — the next lesson covers it in depth.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.