campaign-analytics
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCampaign Analytics
营销活动分析
Production-grade campaign performance analysis with multi-touch attribution modeling, funnel conversion analysis, and ROI calculation. Three Python CLI tools provide deterministic, repeatable analytics using standard library only -- no external dependencies, no API calls, no ML models.
生产级别的营销活动表现分析工具,支持多触点归因建模、漏斗转化分析和ROI计算。三款Python CLI工具仅使用标准库即可提供可确定、可重复的分析结果——无需外部依赖、无需API调用、无需机器学习模型。
Table of Contents
目录
Capabilities
功能特性
- Multi-Touch Attribution: Five attribution models (first-touch, last-touch, linear, time-decay, position-based) with configurable parameters
- Funnel Conversion Analysis: Stage-by-stage conversion rates, drop-off identification, bottleneck detection, and segment comparison
- Campaign ROI Calculation: ROI, ROAS, CPA, CPL, CAC metrics with industry benchmarking and underperformance flagging
- A/B Test Support: Templates for structured A/B test documentation and analysis
- Channel Comparison: Cross-channel performance comparison with normalized metrics
- Executive Reporting: Ready-to-use templates for campaign performance reports
- 多触点归因:五种归因模型(首次触点、末次触点、线性、时间衰减、位置加权),支持参数配置
- 漏斗转化分析:分阶段转化率、流失点识别、瓶颈检测和细分群体对比
- 营销活动ROI计算:ROI、ROAS、CPA、CPL、CAC等指标,支持行业基准对比和表现不佳活动标记
- A/B测试支持:结构化A/B测试文档和分析模板
- 渠道对比:跨渠道表现对比,指标已标准化
- 高管报告:可直接使用的营销活动表现报告模板
Input Requirements
输入要求
All scripts accept a JSON file as positional input argument. See for complete examples.
assets/sample_campaign_data.json所有脚本均接受JSON文件作为位置输入参数。完整示例请查看。
assets/sample_campaign_data.jsonAttribution Analyzer
归因分析器
json
{
"journeys": [
{
"journey_id": "j1",
"touchpoints": [
{"channel": "organic_search", "timestamp": "2025-10-01T10:00:00", "interaction": "click"},
{"channel": "email", "timestamp": "2025-10-05T14:30:00", "interaction": "open"},
{"channel": "paid_search", "timestamp": "2025-10-08T09:15:00", "interaction": "click"}
],
"converted": true,
"revenue": 500.00
}
]
}json
{
"journeys": [
{
"journey_id": "j1",
"touchpoints": [
{"channel": "organic_search", "timestamp": "2025-10-01T10:00:00", "interaction": "click"},
{"channel": "email", "timestamp": "2025-10-05T14:30:00", "interaction": "open"},
{"channel": "paid_search", "timestamp": "2025-10-08T09:15:00", "interaction": "click"}
],
"converted": true,
"revenue": 500.00
}
]
}Funnel Analyzer
漏斗分析器
json
{
"funnel": {
"stages": ["Awareness", "Interest", "Consideration", "Intent", "Purchase"],
"counts": [10000, 5200, 2800, 1400, 420]
}
}json
{
"funnel": {
"stages": ["Awareness", "Interest", "Consideration", "Intent", "Purchase"],
"counts": [10000, 5200, 2800, 1400, 420]
}
}Campaign ROI Calculator
营销活动ROI计算器
json
{
"campaigns": [
{
"name": "Spring Email Campaign",
"channel": "email",
"spend": 5000.00,
"revenue": 25000.00,
"impressions": 50000,
"clicks": 2500,
"leads": 300,
"customers": 45
}
]
}json
{
"campaigns": [
{
"name": "Spring Email Campaign",
"channel": "email",
"spend": 5000.00,
"revenue": 25000.00,
"impressions": 50000,
"clicks": 2500,
"leads": 300,
"customers": 45
}
]
}Output Formats
输出格式
All scripts support two output formats via the flag:
--format- (default): Human-readable tables and summaries for review
--format text - : Machine-readable JSON for integrations and pipelines
--format json
所有脚本通过标志支持两种输出格式:
--format- (默认):便于查看的人类可读表格和摘要
--format text - :便于集成和流水线处理的机器可读JSON格式
--format json
How to Use
使用方法
Attribution Analysis
归因分析
bash
undefinedbash
undefinedRun all 5 attribution models
运行全部5种归因模型
python scripts/attribution_analyzer.py campaign_data.json
python scripts/attribution_analyzer.py campaign_data.json
Run a specific model
运行特定模型
python scripts/attribution_analyzer.py campaign_data.json --model time-decay
python scripts/attribution_analyzer.py campaign_data.json --model time-decay
JSON output for pipeline integration
输出JSON格式用于流水线集成
python scripts/attribution_analyzer.py campaign_data.json --format json
python scripts/attribution_analyzer.py campaign_data.json --format json
Custom time-decay half-life (default: 7 days)
自定义时间衰减半衰期(默认:7天)
python scripts/attribution_analyzer.py campaign_data.json --model time-decay --half-life 14
undefinedpython scripts/attribution_analyzer.py campaign_data.json --model time-decay --half-life 14
undefinedFunnel Analysis
漏斗分析
bash
undefinedbash
undefinedBasic funnel analysis
基础漏斗分析
python scripts/funnel_analyzer.py funnel_data.json
python scripts/funnel_analyzer.py funnel_data.json
JSON output
输出JSON格式
python scripts/funnel_analyzer.py funnel_data.json --format json
undefinedpython scripts/funnel_analyzer.py funnel_data.json --format json
undefinedCampaign ROI Calculation
营销活动ROI计算
bash
undefinedbash
undefinedCalculate ROI metrics for all campaigns
计算所有营销活动的ROI指标
python scripts/campaign_roi_calculator.py campaign_data.json
python scripts/campaign_roi_calculator.py campaign_data.json
JSON output
输出JSON格式
python scripts/campaign_roi_calculator.py campaign_data.json --format json
---python scripts/campaign_roi_calculator.py campaign_data.json --format json
---Scripts
脚本说明
1. attribution_analyzer.py
1. attribution_analyzer.py
Implements five industry-standard attribution models to allocate conversion credit across marketing channels:
| Model | Description | Best For |
|---|---|---|
| First-Touch | 100% credit to first interaction | Brand awareness campaigns |
| Last-Touch | 100% credit to last interaction | Direct response campaigns |
| Linear | Equal credit to all touchpoints | Balanced multi-channel evaluation |
| Time-Decay | More credit to recent touchpoints | Short sales cycles |
| Position-Based | 40/20/40 split (first/middle/last) | Full-funnel marketing |
实现五种行业标准归因模型,用于在营销渠道间分配转化功劳:
| 模型 | 描述 | 适用场景 |
|---|---|---|
| First-Touch | 100%功劳归于首次互动 | 品牌认知类营销活动 |
| Last-Touch | 100%功劳归于末次互动 | 直接响应类营销活动 |
| Linear | 所有触点功劳均等 | 平衡的多渠道评估 |
| Time-Decay | 最近的触点获得更多功劳 | 短销售周期场景 |
| Position-Based | 40/20/40分配(首次/中间/末次) | 全漏斗营销场景 |
2. funnel_analyzer.py
2. funnel_analyzer.py
Analyzes conversion funnels to identify bottlenecks and optimization opportunities:
- Stage-to-stage conversion rates and drop-off percentages
- Automatic bottleneck identification (largest absolute and relative drops)
- Overall funnel conversion rate
- Segment comparison when multiple segments are provided
分析转化漏斗以识别瓶颈和优化机会:
- 分阶段转化率和流失百分比
- 自动识别瓶颈(绝对和相对流失最大的环节)
- 整体漏斗转化率
- 提供多个细分群体时支持群体对比
3. campaign_roi_calculator.py
3. campaign_roi_calculator.py
Calculates comprehensive ROI metrics with industry benchmarking:
- ROI: Return on investment percentage
- ROAS: Return on ad spend ratio
- CPA: Cost per acquisition
- CPL: Cost per lead
- CAC: Customer acquisition cost
- CTR: Click-through rate
- CVR: Conversion rate (leads to customers)
- Flags underperforming campaigns against industry benchmarks
计算全面的ROI指标并提供行业基准对比:
- ROI:投资回报率百分比
- ROAS:广告支出回报率
- CPA:客户获取成本
- CPL:线索获取成本
- CAC:用户获取成本
- CTR:点击率
- CVR:转化率(线索到客户)
- 标记与行业基准相比表现不佳的营销活动
Reference Guides
参考指南
| Guide | Location | Purpose |
|---|---|---|
| Attribution Models Guide | | Deep dive into 5 models with formulas, pros/cons, selection criteria |
| Campaign Metrics Benchmarks | | Industry benchmarks by channel and vertical for CTR, CPC, CPM, CPA, ROAS |
| Funnel Optimization Framework | | Stage-by-stage optimization strategies, common bottlenecks, best practices |
| 指南 | 位置 | 用途 |
|---|---|---|
| 归因模型指南 | | 深入讲解5种模型的公式、优缺点和选择标准 |
| 营销活动指标基准 | | 按渠道和垂直领域划分的行业基准,包括CTR、CPC、CPM、CPA、ROAS等 |
| 漏斗优化框架 | | 分阶段优化策略、常见瓶颈和最佳实践 |
Best Practices
最佳实践
- Use multiple attribution models -- No single model tells the full story. Compare at least 3 models to triangulate channel value.
- Set appropriate lookback windows -- Match your time-decay half-life to your average sales cycle length.
- Segment your funnels -- Always compare segments (channel, cohort, geography) to identify what drives best performance.
- Benchmark against your own history first -- Industry benchmarks provide context, but your own historical data is the most relevant comparison.
- Run ROI analysis at regular intervals -- Weekly for active campaigns, monthly for strategic review.
- Include all costs -- Factor in creative, tooling, and labor costs alongside media spend for accurate ROI.
- Document A/B tests rigorously -- Use the provided template to ensure statistical validity and clear decision criteria.
- 使用多种归因模型——单一模型无法完整呈现全貌。至少对比3种模型以精准评估渠道价值。
- 设置合适的回溯窗口——将时间衰减半衰期与平均销售周期长度匹配。
- 细分漏斗——始终对比不同细分群体(渠道、同期群、地域)以识别驱动最佳表现的因素。
- 先与自身历史数据对比——行业基准提供参考,但自身历史数据是最相关的对比依据。
- 定期进行ROI分析——活跃营销活动每周分析一次,战略回顾每月一次。
- 包含所有成本——除媒体支出外,还需计入创意、工具和人力成本以获得准确的ROI。
- 严谨记录A/B测试——使用提供的模板确保统计有效性和清晰的决策标准。
Limitations
局限性
- No statistical significance testing -- A/B test analysis requires external tools for p-value calculations. Scripts provide descriptive metrics only.
- Standard library only -- No advanced statistical or data processing libraries. Suitable for most campaign sizes but not optimized for datasets exceeding 100K journeys.
- Offline analysis -- Scripts analyze static JSON snapshots. No real-time data connections or API integrations.
- Single-currency -- All monetary values assumed to be in the same currency. No currency conversion support.
- Simplified time-decay -- Uses exponential decay based on configurable half-life. Does not account for weekday/weekend or seasonal patterns.
- No cross-device tracking -- Attribution operates on provided journey data as-is. Cross-device identity resolution must be handled upstream.
- 无统计显著性测试——A/B测试分析需要外部工具进行p值计算。脚本仅提供描述性指标。
- 仅使用标准库——无高级统计或数据处理库。适用于大多数规模的营销活动,但未针对超过10万条用户旅程的数据集优化。
- 离线分析——脚本分析静态JSON快照。无实时数据连接或API集成。
- 单一货币——所有货币值假定为同一币种。不支持货币转换。
- 简化的时间衰减——基于可配置半衰期的指数衰减。未考虑工作日/周末或季节性模式。
- 无跨设备追踪——归因基于提供的用户旅程数据进行。跨设备身份解析需在前置环节处理。