Eliya

ELIYA

@2025 Eliya GmbH

  • Blog
  • Use Cases
  • Solutions
  • About
  • Contact Us
  • Privacy Policy
    Published on August 22, 2025

    Practical Guide For Meridian MMM: From Zero To Hero

    Writen by:
    Neeraj Bhauryal
    12 minutes estimated reading time

    Learn how to set up and run your first Media Mix Modeling (MMM) project with Google Meridian. This guide covers key features, installation, and a step-by-step walk-through of the code to help you go from zero to hero.

    Practical Step-by-Step Guide to Meridian MMM

    In today's complex digital landscape, understanding the true impact of your marketing efforts is more crucial than ever. As consumer journeys become increasingly fragmented and privacy regulations evolve, traditional measurement methods often fall short.

    This is where Google Meridian steps in, it’s an advanced, open-source Media Mix Modeling (MMM) framework designed to help marketers and data scientists make smarter, data-driven decisions. Whether you're running ads on TV, search, social, or YouTube, Meridian uses advanced Bayesian modeling to quantify each channel’s contribution, and even recommends how to optimize future budgets.

    For a more in-depth introduction to Meridian, check out our related blogs here and here.

    In this blog, I will walk you through how to set up Meridian and how to run your first model using your own marketing data.

    Key Features and Benefits of Meridian

    Google Meridian is more than just an open-source MMM tool, it's a modern, transparent, and highly customizable framework designed to meet today’s marketing measurement challenges. Here’s what makes it stand out:

    1. Bayesian Causal Inference

    Meridian uses Bayesian statistics to estimate the causal impact of each marketing channel. This approach doesn't just give you a single ROI number, rather , it provides a range of possible outcomes, making your estimates more realistic and reliable, especially under uncertainty.

    2. Geo-Level Hierarchical Modeling

    Whether you're analyzing performance across states, countries, or store locations, Meridian supports hierarchical models. Regions share statistical strength, improving forecast accuracy and allowing more granular insights, even for regions with limited data.

    3. Time‑Varying Intercepts for Seasonality & Growth

    Instead of assuming a flat baseline, Meridian includes dynamic intercepts that adapt over time. This accounts for seasonality, organic growth, and other time-based trends, ensuring media effects aren’t confused with natural fluctuations in business performance.

    4. Adstock & Saturation Modeling

    The media doesn't work instantly, and spending has limits. Meridian models both:

    • Adstock: the lagged effect of media spend over time
    • Saturation: diminishing returns as you spend more

    This gives you a much more realistic view of media performance and ROI.

    5. Integration of Google Query Volume (GQV) & Reach/Frequency Data

    You can enhance your model with Google Query Volume (GQV) to control for organic interest and YouTube reach/frequency data to better model video campaign effectiveness. This leads to less biased attribution and better-informed media decisions.

    6. Fully Open Source & Customization

    Meridian’s open-source nature means you’re in control. You can:

    • Adjust priors and model structure
    • Modify media effect distributions
    • Add your own control variables or business logic
    • Integrate with custom data pipelines (e.g. BigQuery, S3)

    It’s ideal for teams who want flexibility and transparency in their measurement.

    7. Built-in Budget Optimization

    Once the model is trained, Meridian can recommend how to reallocate your budget across channels to maximize conversions or ROI, while respecting saturation effects. It's not just analytics, it’s actionable planning support.


    Installing Google Meridian

    Before installing, make sure you're using Python 3.11 or 3.12.GPU support (like NVIDIA T4 or V100) is recommended for faster performance, but CPU-only environments are also supported.

    Install via pip:

    1# For GPU-enabled environments (recommended)
    2!pip install --upgrade 'google-meridian[and-cuda]'
    3
    4# For macOS or CPU-only environments
    5!pip install --upgrade 'google-meridian'
    6
    7# To install the latest development version (optional)
    8!pip install --upgrade git+https://github.com/google/meridian.git

    Running Google Meridian

    For a deeper dive into the full analysis and implementation, we recommend looking at our repository. It includes code, data samples and extended examples.

    Loading the dataset

    This section defines the structure of your dataset by mapping your media, spend, and control columns to the appropriate MMM inputs.

    • channels lists the main media channels you're analyzing (e.g., Channel0, Channel1, Channel2).
    • CoordToColumns tells Meridian how to interpret your dataset: which columns represent media impressions, media spend, controls, reach/frequency data, and the KPI (like conversions).
    • The *_to_channel dictionaries link your raw data column names back to their logical channel names, so Meridian knows how to group and interpret them properly, especially for visualization and attribution.


    1channels = ["Channel0", "Channel1", "Channel2"]
    2
    3coord_to_columns = load.CoordToColumns(
    4    controls=[
    5        "sentiment_score_control",
    6        "competitor_activity_score_control"
    7    ],
    8    kpi='conversions',
    9    media=[f"{channel}_impression" for channel in channels],
    10    media_spend=[f"{channel}_spend" for channel in channels],
    11    reach=["Channel3_reach"],
    12    frequency=["Channel3_frequency"],
    13    rf_spend=["Channel3_spend"],
    14)
    15
    16correct_media_to_channel = {
    17    f"{channel}_impression": channel for channel in channels 
    18}
    19
    20correct_media_spend_to_channel = {
    21    f"{channel}_spend": channel for channel in channels
    22}
    23
    24correct_reach_to_channel = {
    25    "Channel3_reach": "Channel3"
    26}
    27
    28correct_frequency_to_channel = {
    29    "Channel3_frequency": "Channel3"
    30}
    31
    32correct_rf_spend_to_channel = {
    33    "Channel3_spend": "Channel3"
    34}
    35

    This section loads your marketing data from a CSV file into Meridian.

    • CsvDataLoader reads the dataset using the column mappings you defined earlier.
    • csv_path points to the location of your CSV file.
    • coord_to_columns tells Meridian how to interpret each column (e.g. which are media, controls, etc.).
    • The media_to_channel and media_spend_to_channel mappings ensure each media metric is correctly linked to its respective channel.

    Finally, loader.load() loads the data into a format that Meridian can use for modeling.

    1loader = load.CsvDataLoader(
    2    csv_path=f'/{PATH}/{FILENAME}.csv',
    3    coord_to_columns=coord_to_columns,
    4    media_to_channel=correct_media_to_channel,
    5    media_spend_to_channel=correct_media_spend_to_channel,
    6)
    7data = loader.load()

    Configure the model

    This block sets up the modeling assumptions and initializes the Meridian model.

    • roi_rf_mu and roi_rf_sigma define the prior belief (mean and uncertainty) about the return on investment (ROI) for channels using reach & frequency data.
    • A log-normal distribution is used for the prior, which is common for modeling ROI since it’s always positive and often skewed.
    • ModelSpec holds this prior configuration.
    • Finally, Meridian() initializes the model using the loaded dataset (data) and your specified priors.

    This step prepares the model for training based on your business expectations and data structure.

    1roi_rf_mu = 0.2 
    2roi_rf_sigma = 0.9
    3prior = prior_distribution.PriorDistribution(
    4    roi_rf=tfp.distributions.LogNormal(
    5        roi_rf_mu, roi_rf_sigma, name=constants.ROI_RF
    6    )
    7)
    8model_spec = spec.ModelSpec(prior=prior)
    9
    10mmm = model.Meridian(input_data=data, model_spec=model_spec)

    This section runs the model’s sampling process to estimate media impact using Bayesian inference.

    • sample_prior(500) draws 500 samples from the prior distribution — useful for checking if your prior assumptions are reasonable before training.
    • sample_posterior(...) runs the actual Bayesian model fitting using Markov Chain Monte Carlo (MCMC):
      • n_chains=4: runs 4 parallel sampling chains
      • n_adapt=500: adaptation steps for tuning the sampler
      • n_burnin=500: burn-in samples (ignored in the final results)
      • n_keep=1000: number of posterior samples to retain
      • seed=1: ensures reproducibility

    This is where the model learns the relationships between spend, impressions, and conversions.

    1mmm.sample_prior(500)
    2mmm.sample_posterior(
    3    n_chains=4, n_adapt=500, n_burnin=500, n_keep=1000, seed=1)


    Analyzing the results

    Convergence of the model

    This block checks the convergence diagnostics of your model to ensure the sampling worked correctly. ModelDiagnostics(mmm) creates a diagnostics object based on your trained model and plot_rhat_boxplot() visualizes the R-hat values (a key convergence metric for MCMC sampling).

    1model_diagnostics = visualizer.ModelDiagnostics(mmm)
    2model_diagnostics.plot_rhat_boxplot()

    Boxplot showing convergence diagnostics for Meridian

    Comparing prior and posterior distributions

    This step visualizes the difference between your prior assumptions and the posterior results after training.

    • plot_prior_and_posterior_distribution() compares the distributions for each parameter (like ROI) before and after the model sees your data.
    • This helps you understand how much the data influenced the model’s beliefs, and whether your priors were too strong or too vague.

    It’s a great way to verify if the model is learning from the data in a meaningful way.

    1model_diagnostics = visualizer.ModelDiagnostics(mmm)
    2model_diagnostics.plot_prior_and_posterior_distribution()


    visualizing difference between prior distribution and posterior results in Meridian MMM

    R-squared, MAPE and wMAPE metrics

    This part evaluates how well the model fits your data by generating a predictive accuracy table.

    • predictive_accuracy_table() shows metrics like mean absolute error (MAE) and R-squared for each region or overall.
    • These metrics help you assess how accurately the model predicts your KPI (e.g. conversions) based on media inputs.

    Use this step to check if your model performs well and is ready for interpretation or optimization.

    1model_diagnostics = visualizer.ModelDiagnostics(mmm)
    2model_diagnostics.predictive_accuracy_table()
    MAPE and R Squared results in Meridian MMM

    Model fit

    This block creates a visual comparison between the actual KPI values and the values predicted by the model.

    • plot_model_fit() generates a line chart that overlays the model’s predicted conversions (or revenue) against the true observed data over time.
    • This helps you visually assess how well the model tracks the real-world performance of your business.

    If the lines align closely, it means your model is fitting the data well.

    1model_fit = visualizer.ModelFit(mmm)
    2model_fit.plot_model_fit()
    Actuals vs Predictions in Meridian MMM

    Generate results HTML report

    To generate a two page HTML report, try the following example where filepath is the path where you want to save the HTML file


    1summarizer = summarizer.Summarizer(mmm)
    2filepath = '/reports/'
    3start_date = '2021-01-25'
    4end_date = '2024-01-15'
    5summarizer.output_model_results_summary(f'summary_output.html',
    6                                        filepath,
    7                                        start_date,
    8                                        end_date)

    The following are examples of the visualizations automatically generated by Meridian as part of its HTML report. These plots provide powerful insights into media performance.

    The first plot shows the breakdown of KPI by the baseline and all marketing channels.


    Contribution of different channels in Meridian MMM

    The plot below compares the ROI of each media channel with its effectiveness, measured as the incremental outcome per impression. Each bubble represents a channel, with its size indicating the total media spend, allowing for a clear visual understanding of which channels deliver the best return at scale.


    ROI vs Effectiveness in Meridian MMM

    For the plot below, marginal ROI measures the additional return generated for every additional dollar spend. It indicates how effective every additional spend is.


    ROI vs Marginal ROI (mROI) in MMM Meridian

    The next plot shows the credible intervals for ROIs for the channels.


    ROI per channel in Meridian MMM

    The following response curves are built using historical media flighting patterns and illustrate the total incremental impact on the KPI as media spend accumulates over the selected time period.


    Response curves diminishing return in Meridian MMM

    Finally, the model generates the plot for reach and frequency data, whenever it is available, the plot suggests the optimal frequency level that maximizes ROI for the given channel. In the example at consideration the model suggests us to maintain an average weekly impressions of 1.6 to maximize the ROI for Channel3.


    Frequency vs. ROI in Meridian MMM

    Budget Optimization and generating report

    This step runs budget optimization based on your model’s results.

    • BudgetOptimizer(mmm) initializes the optimizer using your trained model.
    • optimize(use_kpi=True) calculates how to reallocate your media budget to maximize your target KPI (like conversions or revenue), while accounting for diminishing returns and historical performance. In the example at hand KPI is conversions.

    This is where Meridian turns insights into actionable recommendations.

    1%%time
    2budget_optimizer = optimizer.BudgetOptimizer(mmm)
    3optimization_results = budget_optimizer.optimize(use_kpi=True)

    And finally to display html for the budget report, we do the following


    1filepath = './reports/'
    2optimization_results.output_optimization_summary(
    3    'optimization_output.html', filepath
    4)
    5IPython.display.HTML(filename='./reports/optimization_output.html')

    The plot below visualizes the recommended budget allocation across channels based on the model's optimization, aiming to maximize ROI while accounting for diminishing returns.

    Optimized vs non-optimized spend per channel in Meridian MMM


    In the following plot, each bar represents the change in spend for a channel after optimization. Positive values indicate an increase in budget compared to the original allocation, while negative values suggest a reduction in spend.


    Changed in optimized spend per channel in MMM

    In the plot below, the leftmost bar represents the incremental KPI before optimization, while the other bars show the change in incremental KPI for each channel based on the optimized spend levels. The rightmost bar displays the total incremental KPI achieved after optimization.


    Optimized incremental KPI across all channels in MMM

    Summary

    Google Meridian represents a modern, flexible, and open approach to marketing mix modeling, ideal for digitally focused organizations with analytical resources.

    Key drawcards:

    • Bayesian causal inference for robust estimation
    • Geo-hierarchical modeling for regional granularity
    • Seasonality and growth adjustment via time-varying intercepts
    • Adstock and saturation modeling for realistic response curves
    • Integration of search and reach/frequency data (e.g., GQV, YouTube)
    • Full open-source control though an open Python codebase
    • Actionable budget optimization built into the workflow

    Getting Meridian up and running involves installing it via PyPI, preparing and loading data, configuring your model spec, running MCMC sampling, and visualizing results. Google's colab notebooks and data platforms (Cortex, MMM Data Platform) help streamline that process.

    If you're building MMM capabilities and already use Google Ads, YouTube, or BigQuery or just want greater flexibility and control than off-the-shelf solutions Meridian is definitely worth exploring.

    FAQs

    1. What is Google Meridian?

    Google Meridian is an advanced, open-source Marketing Mix Modeling (MMM) framework designed to help marketers and data scientists measure the true impact of their marketing efforts across various channels (TV, search, social, YouTube) and optimize future budget allocation.

    2. How does Meridian differ from traditional MMM tools?

    Meridian stands out with its use of Bayesian causal inference for more reliable ROI estimates, geo-level hierarchical modeling for granular insights, time-varying intercepts to account for seasonality, and built-in adstock and saturation modeling for a realistic view of media performance. It also integrates Google Query Volume (GQV) and reach/frequency data for less biased attribution.

    3. Is Google Meridian open-source?

    Yes, Google Meridian is fully open-source. This allows users to customize the model structure, adjust priors, modify media effect distributions, add control variables, and integrate with custom data pipelines like BigQuery or S3.

    4. What are the system requirements for installing Google Meridian?

    Google Meridian requires Python 3.11 or 3.12. While CPU-only environments are supported, GPU support (e.g., NVIDIA T4 or V100) is recommended for faster performance. Given that Meridian is implemented with Tensorflow (Tensorflow Probability), using GPU can greatly reduce run time.

    5. How does Meridian help with budget optimization?

    After training the model, Meridian can recommend how to reallocate your marketing budget across different channels to maximize conversions or ROI, taking into account saturation effects and historical performance. Meridian does not perform prediction or forecasting. Hence, it’s not designed to optimize future spend allocations.

    6. What kind of reports and visualizations does Meridian generate?

    Meridian automatically generates a two-page HTML report with various visualizations, including KPI breakdowns by baseline and marketing channels, ROI vs. Effectiveness plots, marginal ROI charts, credible intervals for ROIs, response curves, and optimal frequency level suggestions based on reach and frequency data. It also provides budget optimization reports.

    7. Can Meridian be used for specific geographic regions?

    Yes, Meridian supports geo-level hierarchical modeling, allowing you to analyze performance across states, countries, or store locations. This feature improves forecast accuracy and provides more granular insights, even for regions with limited data.

    8. What convergence diagnostics are available in Meridian?

    Meridian provides model diagnostics such as R-hat boxplots to check sampling convergence, and visualizations to compare prior and posterior distributions. It also generates predictive accuracy tables with metrics like R-squared, MAPE, and wMAPE to evaluate model fit.



    Similar Posts in Media Mix Modeling

    Media Mix ModelingMastering Media Mix Modeling With Google Meridian MMM

    Google Meridian MMM: The 2025 Guide For Marketers

    Discover how Google Meridian MMM helps marketers model channel impact, optimize ...

    May 21, 2025

    Media Mix ModelingPractical Step-by-Step Guide to Meridian MMM

    Practical Guide For Meridian MMM: From Zero To Hero

    Learn how to set up and run your first Media Mix Modeling (MMM) project with ...

    August 22, 2025

    Media Mix ModelingA Complete Guide to Meridian vs Robyn

    Meridian Vs Robyn: Which Tool Is Right For Your Business In 2025?

    Compare Meridian vs Robyn on features, pricing, and usability to find the right ...

    May 22, 2025