An end-to-end Multi-Touch Attribution pipeline implementing 7 attribution models — from simple rule-based approaches to data-driven Markov Chain and Shapley Value models — with a full MTA vs MMM reconciliation framework. Built on 50,000 synthetic user journeys across 6 marketing channels.
- Which marketing channels actually drive conversions — not just which ones get the last click?
- How does attribution change when we use data-driven vs rule-based methods?
- Where do MTA and MMM disagree, and what does that tell us about measurement gaps?
- What is the true ROI of each channel after removing last-touch bias?
mta_model/
├── outputs/ # Charts, CSVs, executive summary
├── src/
│ ├── data_prep.py # 50,000 synthetic user journeys (6 channels)
│ ├── rule_based.py # 5 rule-based models
│ ├── markov_chain.py # Markov Chain removal effect model
│ ├── shapley.py # Shapley Value attribution (game theory)
│ ├── mmm_reconciliation.py # MTA vs MMM reconciliation framework
│ └── visualizations.py # 8 charts + summary dashboard
├── main.py # Run the full pipeline
├── requirements.txt
└── README.md
| Model | Logic | Best For |
|---|---|---|
| Last Touch | 100% credit to final touchpoint | Direct response; ad platform default |
| First Touch | 100% credit to first touchpoint | Awareness and acquisition focus |
| Linear | Equal credit across all touches | Long complex sales cycles |
| Time Decay | More credit to recent touches | Short sales cycles |
| Position-Based | 40% first / 40% last / 20% middle | Balanced acquisition + conversion |
Markov Chain (Removal Effect)
- Builds a transition probability matrix from channel → channel → conversion
- For each channel, measures how much overall conversion rate drops when that channel is removed
- This "removal effect" is the channel's true causal contribution
Shapley Values (Game Theory)
- Treats the customer journey as a cooperative game where channels are players
- Computes the average marginal contribution of each channel across all possible channel orderings
- Satisfies 4 mathematical fairness axioms (efficiency, symmetry, dummy, additivity)
- Foundation of SHAP values used in modern ML explainability
Compares MTA outputs against Marketing Mix Model (MMM) channel attribution to identify:
- Strong agreement (high confidence in both signals)
- MTA inflation (last-touch bias overstating lower-funnel channels)
- MMM premium (brand/awareness effects that MTA's digital tracking misses)
Decision Framework:
MMM → Annual budget allocation, CFO conversations, offline channels
MTA → Weekly campaign optimization, bid strategy, creative testing
Reconciliation → Where signals diverge most = where to investigate
| File | Description |
|---|---|
01_journey_distribution.png |
Journey length by conversion outcome |
02_channel_positions.png |
First touch, last touch, overall share by channel |
03_rule_based_comparison.png |
All 5 rule-based models side by side |
04_transition_heatmap.png |
Markov Chain transition probability matrix |
05_data_driven_vs_rule_based.png |
Markov + Shapley vs Last Touch baseline |
06_mta_mmm_reconciliation.png |
Channel share divergence between MTA and MMM |
07_roi_comparison.png |
MTA ROI vs MMM ROI per channel |
08_summary_dashboard.png |
Full summary dashboard |
rule_based_results.csv |
All rule-based model outputs |
markov_results.csv |
Markov Chain attribution |
shapley_results.csv |
Shapley Value attribution |
mta_mmm_reconciliation.csv |
Full reconciliation table |
mta_executive_summary.txt |
Business-ready summary with recommendations |
git clone https://github.com/yourusername/mta_model.git
cd mta_model
pip install -r requirements.txt
python main.pyNote: The Shapley model evaluates 64 channel subsets across 50,000 users — allow 2-3 minutes for this step.
No data download required — data is generated synthetically with realistic multi-channel journey patterns.
- Python 3.14+
pandas/numpy— journey data processingscipy— statistical utilitiesmatplotlib— all visualizations- Pure Python — Markov Chain matrix operations and Shapley computation
- Multi-channel customer journey simulation
- Rule-based attribution (Last Touch, First Touch, Linear, Time Decay, Position-Based)
- Markov Chain transition matrices and removal effect calculation
- Shapley Value computation from cooperative game theory
- MTA vs MMM reconciliation framework
- Channel-level ROI measurement and comparison
- Attribution bias identification (last-touch inflation, brand effect gaps)
- Executive-ready measurement reporting
- Shapley (1953) — A Value for n-Person Games — original game theory paper
- Markov Chain MTA — standard in production measurement at Google, Meta, Amazon
- MTA vs MMM reconciliation — growing best practice in sophisticated measurement teams
Built as part of a data science / marketing analytics portfolio.
Background: 15+ years in Marketing Analytics | SQL | Python | Statistical Modeling | MMM | MTA