Unraveling Marketing Metrics with Statistical & Causal Modeling in Python
Introduction
In today’s data-driven marketing environment, leaders are challenged to not only measure key performance metrics but also understand what truly drives them. Conversion rate, revenue, and Return on Ad Spend (ROAS) are among the most critical indicators of marketing success. The conversion rate describes the ratio of visits or clicks that lead to a desired action, such as purchases or sign-ups [1]. ROAS refers to the revenue earned for every dollar spent on advertising [2], directly reflecting campaign efficiency. Understanding fluctuations in these metrics is vital for decision-makers focused on growth and ROI.
However, bridging the gap between complex data analysis and actionable business insight remains a challenge. Frequently, advanced analytics and models fail to yield business impact because they are misunderstood or not effectively communicated between data science teams and executive leadership [3]. Decision-makers need more than surface-level correlations — they need to discern true cause-and-effect behind marketing outcomes [4].
This article explores how combining statistical modeling and causal inference techniques in Python can illuminate the drivers of key marketing metrics. Using libraries like statsmodels for regression, DoWhy for causal inference, and causalimpact for time-series intervention analysis, we will demonstrate how analysts can produce insights that both technical teams and executives can act upon.
Statistical Modeling: Regression Analysis for Marketing KPIs
Regression analysis is one of the most widely used methods for identifying relationships between marketing inputs and outcomes. For example, we may want to know how ad spend and web traffic jointly influence revenue.
import pandas as pd
import statsmodels.api as sm
# Hypothetical dataset
data = {
'Ad_Spend': [50, 80, 60, 90, 120, 70, 100, 110], # $ thousands
'Web_Traffic': [1.2, 1.6, 1.3, 1.8, 2.5, 1.4, 2.0, 2.2], # millions of visits
'Revenue': [200, 270, 220, 310, 400, 250, 330, 360] # $ thousands
}
df = pd.DataFrame(data)
X = sm.add_constant(df[['Ad_Spend', 'Web_Traffic']])
y = df['Revenue']
model = sm.OLS(y, X).fit()
print(model.summary())The results indicate which drivers are statistically significant and quantify their effect sizes. For instance, each additional $1,000 in ad spend might increase revenue by $3,000–$4,000 (p < 0.01). Web traffic may show a different level of significance. Regression outputs also include R-squared (how much of the variation is explained) and confidence intervals for each factor [5].
These results help executives prioritize spending: regression transforms correlations into an evidence-backed story about where the biggest drivers of revenue lie.
Hypothesis Testing and Statistical Significance
Regression is complemented by hypothesis testing, especially in A/B experiments. Suppose we test two landing pages:
- Page A: 100 conversions / 1,000 visitors (10%)
- Page B: 130 conversions / 1,000 visitors (13%)
We want to know if the difference is statistically significant.
import numpy as np
import statsmodels.stats.proportion as smp
conversions = np.array([100, 130])
visitors = np.array([1000, 1000])
stat, p_value = smp.proportions_ztest(count=conversions, nobs=visitors)
print(f"Z-statistic: {stat:.2f}, p-value: {p_value:.3f}")If the p-value is 0.035, the improvement is significant at the 5% level. Page B likely does convert better. Importantly, analysts must also emphasize practical significance: does a 3% increase translate into enough incremental revenue to justify design or ad costs? [8]
Causal Inference: From Correlation to Causation
Executives often ask: “Did our campaign actually cause this lift?” Causal inference helps answer this.
DoWhy Example
Using DoWhy, we can estimate the causal effect of offering coupons on conversion rate:
from dowhy import CausalModel
model = CausalModel(
data=df,
treatment='coupon',
outcome='converted',
common_causes=['prior_visits', 'age', 'channel']
)
identified_estimand = model.identify_effect()
causal_estimate = model.estimate_effect(
identified_estimand,
method_name="backdoor.propensity_score_matching"
)
print(causal_estimate.value)This approach controls for confounders like prior visits or demographics. It might show that coupons increase conversion probability by 4 percentage points — a causal statement, not just correlation [7][9].
CausalImpact Example
For time series interventions (e.g., campaigns), causalimpact estimates what would have happened without the intervention [6].
from causalimpact import CausalImpact pre_period = ['2025-01-01', '2025-03-31'] post_period = ['2025-04-01', '2025-04-07'] impact = CausalImpact(sales_data, pre_period, post_period) print(impact.summary())
The output quantifies lift (e.g., +20% revenue with 95% confidence) and helps executives assess whether a campaign truly worked [4].
Bridging Technical Insights with Business Strategy
Numbers alone don’t drive value — interpretation does. Analysts must communicate in ways executives can trust:
- Focus on the “Why”: Translate coefficients into business implications (“$1k more ad spend yields ~$4k revenue”) [3].
- Simplify and Visualize: Plots of predicted vs. actual performance clarify impact.
- Highlight Practical Significance: Not just “statistically significant” — but is it big enough to matter? [8]
- Use Causal Insights for Decisions: “Had we not run this ad, sales would be 20% lower.”
- Validate and Iterate: Pair observational causal models with controlled experiments when possible.
As one industry article notes, data storytelling — blending narrative, visuals, and numbers — is not optional but essential to turn insights into action [3].
Conclusion
By combining statistical modeling with causal inference, marketers and executives can move from surface-level metrics to deeper insight. Regression quantifies associations; hypothesis testing validates real effects; causal inference uncovers what actions truly drive conversion, revenue, and ROAS.
When analysts communicate these results clearly and in business terms, executives can act with confidence. The result: smarter investments, optimized campaigns, and marketing strategies grounded in evidence rather than guesswork.
About the Author
Brian Curry is a Kansas City–based Data Scientist, Artificial Intelligence expert and founder of Vector1 Research, a part time passion project, where he explores the frontier of AI, SEO, Machine Learning, Economic Systems, Marketing Modeling, and Econometrics. His work focuses on building intelligent systems that reveal the causal structures driving performance across marketing, content, and economics and the creator of Papilon, an open-source framework for complex system optimization, and Daedalus, a platform for causal and economic analysis.
References & Acknowledgments
[1] Fuchs, M. (2020). Marketing — Conversion Rate Analytics.
https://towardsdatascience.com/marketing-conversion-rate-analytics
[2] Adjust. What is return on ad spend (ROAS)?
https://www.adjust.com/glossary/return-on-ad-spend/
[3] Fuzzitech (2025). Bridging the Gap Between Data Science and Decision-Makers Through Data Storytelling.
https://fuzzitech.com/data-storytelling
[4] Katy (2025). Causal Impact Analysis in Time Series with Python.
https://medium.com/causal-impact-python
[5] DataRobot Blog (2019). A Guide to Multiple Regression Using Statsmodels.
https://www.datarobot.com/blog/multiple-regression-using-statsmodels/
[6] Khushaktov, F. (2023). How to use Causal Impact in Python (Example).
https://towardsdatascience.com/causal-impact-in-python-example
[7] DataCamp (2024). Intro to Causal Inference with DoWhy.
https://www.datacamp.com/tutorial/dowhy-intro
[8] Harvard Business Review (2016). A Refresher on Statistical Significance.
https://hbr.org/2016/02/a-refresher-on-statistical-significance
[9] AWS Open Source Blog (2023). Root Cause Analysis with DoWhy.
https://aws.amazon.com/blogs/opensource/root-cause-analysis-dowhy/
[10] Acknowledgment: This article was co-authored with the assistance of ChatGPT, an AI language model developed by OpenAI.


