What you’ll learn: What MMM is and why it’s resurging. How to set up Meta’s Robyn for automated marketing mix modeling. How to interpret results and optimize budget allocation.
Marketing Mix Modeling quantifies the incremental impact of each marketing channel on a business KPI like sales or leads. Unlike attribution modeling, MMM does not require user-level tracking—it uses aggregate data. With third-party cookies disappearing and privacy regulations tightening, MMM has resurged as the gold standard for cross-channel measurement. Meta’s Robyn, Google’s Meridian, and open-source pymc-marketing are the leading tools.
MMM reveals the true incremental contribution of each channel—including offline channels like TV, radio, and print that attribution models cannot track. It accounts for external factors like seasonality, competitor activity, and economic conditions. And critically, it reveals diminishing returns curves that show you exactly where adding more spend to a channel stops producing proportional returns.
# Robyn requires R installed on your machine even for Python version
# Download R: https://cran.r-project.org
# Create virtual environment
python3 -m venv robyn-env
source robyn-env/bin/activate # Mac/Linux
# robyn-env\Scripts\activate # Windows
# Install from PyPI
pip install robynpy
# OR install dev version from GitHub:
git clone https://github.com/facebookexperimental/Robyn.git
cd Robyn
pip install -r requirements.txt
# Robyn needs a time-series dataframe with:
# - Date column (daily, weekly, or monthly)
# - Dependent variable (revenue, leads, etc.)
# - Media spend columns (Google, Meta, Amazon, TV, etc.)
# - Control variables (price, promotions, holidays, etc.)
import pandas as pd
# Example data structure:
data = pd.DataFrame({
'date': pd.date_range('2024-01-01', periods=104, freq='W'),
'revenue': [...], # Your weekly revenue
'google_spend': [...], # Google Ads weekly spend
'meta_spend': [...], # Meta Ads weekly spend
'amazon_spend': [...], # Amazon Ads weekly spend
'email_sends': [...], # Email marketing volume
'price_index': [...], # Average product price
'competitor_index': [...], # Competitor activity metric
'holiday_flag': [...] # 1 for holiday weeks, 0 otherwise
})
# Minimum: 2 years of weekly data (104 rows)
# Robyn needs enough data to detect patterns and seasonality
print(f'Data: {len(data)} weeks, {data.columns.tolist()}')
from robyn import Robyn
# Configure the model
robyn = Robyn()
robyn.set_data(
data=data,
dep_var='revenue',
date_var='date',
paid_media_vars=['google_spend', 'meta_spend', 'amazon_spend'],
paid_media_signs=['positive', 'positive', 'positive'],
organic_vars=['email_sends'],
context_vars=['price_index', 'competitor_index', 'holiday_flag'],
adstock='geometric', # or 'weibull_cdf'
window_start='2024-01-01',
window_end='2025-12-31'
)
# Set hyperparameter ranges
robyn.set_hyperparameters({
'google_spend_alphas': [0.5, 3], # Saturation shape
'google_spend_gammas': [0.3, 1], # Saturation inflection
'google_spend_thetas': [0, 0.3], # Adstock decay (digital: 0-0.3)
'meta_spend_alphas': [0.5, 3],
'meta_spend_gammas': [0.3, 1],
'meta_spend_thetas': [0, 0.3],
'amazon_spend_alphas': [0.5, 3],
'amazon_spend_gammas': [0.3, 1],
'amazon_spend_thetas': [0, 0.3],
})
# Run optimization (this takes 10-30 minutes)
results = robyn.run(
iterations=2000, # More = better but slower
trials=5, # Number of Nevergrad trials
ts_validation=True # Time-series cross-validation
)
# View Pareto-optimal model solutions
robyn.plot_results()
# Key outputs from Robyn:
# 1. Channel decomposition - how much revenue each channel drove
# 2. Saturation curves - diminishing returns for each channel
# 3. Adstock effects - how long each channel's impact lasts
# 4. Budget allocator - optimal spend per channel
# Run budget optimization
optimal = robyn.budget_allocator(
total_budget=100000, # Monthly budget to optimize
date_range=['2026-03-01', '2026-03-31']
)
print('Optimal Budget Allocation:')
for channel, amount in optimal.items():
print(f' {channel}: ${amount:,.2f}')
Website: googleadsagent.ai | GitHub: https://github.com/itallstartedwithaidea | Tools: googleadsagent.ai/tools
John Williams | Senior Paid Media Specialist, Seer Interactive | $48M+ managed spend | Creator, GoogleAdsAgent.ai | Hero Conf Speaker | github.com/itallstartedwithaidea
PART TWO
10 Quick-Start How-To Guides
Targeted guides for specific sub-topics from the AI Landscape Map
Get a free 30-day audit of your advertising accounts. John will personally review your setup and provide actionable recommendations.
John will review your account and reach out within 24 hours.