Get the FREE Ultimate OpenClaw Setup Guide →

campaign-analytics

npx machina-cli add skill alirezarezvani/claude-skills/campaign-analytics --openclaw
Files (1)
SKILL.md
7.5 KB

Campaign 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.


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

Input Requirements

All scripts accept a JSON file as positional input argument. See assets/sample_campaign_data.json for complete examples.

Attribution Analyzer

{
  "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

{
  "funnel": {
    "stages": ["Awareness", "Interest", "Consideration", "Intent", "Purchase"],
    "counts": [10000, 5200, 2800, 1400, 420]
  }
}

Campaign ROI Calculator

{
  "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 --format flag:

  • --format text (default): Human-readable tables and summaries for review
  • --format json: Machine-readable JSON for integrations and pipelines

How to Use

Attribution Analysis

# Run all 5 attribution models
python scripts/attribution_analyzer.py campaign_data.json

# Run a specific model
python scripts/attribution_analyzer.py campaign_data.json --model time-decay

# JSON output for pipeline integration
python scripts/attribution_analyzer.py campaign_data.json --format json

# Custom time-decay half-life (default: 7 days)
python scripts/attribution_analyzer.py campaign_data.json --model time-decay --half-life 14

Funnel Analysis

# Basic funnel analysis
python scripts/funnel_analyzer.py funnel_data.json

# JSON output
python scripts/funnel_analyzer.py funnel_data.json --format json

Campaign ROI Calculation

# Calculate ROI metrics for all campaigns
python scripts/campaign_roi_calculator.py campaign_data.json

# JSON output
python scripts/campaign_roi_calculator.py campaign_data.json --format json

Scripts

1. attribution_analyzer.py

Implements five industry-standard attribution models to allocate conversion credit across marketing channels:

ModelDescriptionBest For
First-Touch100% credit to first interactionBrand awareness campaigns
Last-Touch100% credit to last interactionDirect response campaigns
LinearEqual credit to all touchpointsBalanced multi-channel evaluation
Time-DecayMore credit to recent touchpointsShort sales cycles
Position-Based40/20/40 split (first/middle/last)Full-funnel marketing

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

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

Reference Guides

GuideLocationPurpose
Attribution Models Guidereferences/attribution-models-guide.mdDeep dive into 5 models with formulas, pros/cons, selection criteria
Campaign Metrics Benchmarksreferences/campaign-metrics-benchmarks.mdIndustry benchmarks by channel and vertical for CTR, CPC, CPM, CPA, ROAS
Funnel Optimization Frameworkreferences/funnel-optimization-framework.mdStage-by-stage optimization strategies, common bottlenecks, best practices

Best Practices

  1. Use multiple attribution models -- No single model tells the full story. Compare at least 3 models to triangulate channel value.
  2. Set appropriate lookback windows -- Match your time-decay half-life to your average sales cycle length.
  3. Segment your funnels -- Always compare segments (channel, cohort, geography) to identify what drives best performance.
  4. Benchmark against your own history first -- Industry benchmarks provide context, but your own historical data is the most relevant comparison.
  5. Run ROI analysis at regular intervals -- Weekly for active campaigns, monthly for strategic review.
  6. Include all costs -- Factor in creative, tooling, and labor costs alongside media spend for accurate ROI.
  7. Document A/B tests rigorously -- Use the provided template to ensure statistical validity and clear decision criteria.

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.

Source

git clone https://github.com/alirezarezvani/claude-skills/blob/main/marketing-skill/campaign-analytics/SKILL.mdView on GitHub

Overview

Campaign Analytics provides production-grade analysis of marketing campaigns using multi-touch attribution, funnel conversion, and ROI calculations. It ships three Python CLI tools that deliver deterministic, repeatable insights with only the standard library (no external dependencies or ML models). It also includes A/B test templates and cross-channel comparison features to inform optimization and reporting.

How This Skill Works

Three Python CLI tools (attribution_analyzer.py, funnel_analyzer.py, campaign_roi_calculator.py) consume a JSON input file and produce metrics via deterministic analyses using only the standard library. You can run all five attribution models or a specific one, and choose text or json outputs for integration. Outputs support ready-to-ship dashboards and executive reports.

When to Use It

  • When optimizing cross-channel campaigns, analyze multi-touch attribution to credit conversions.
  • When diagnosing funnel performance, identify bottlenecks and drop-off stages.
  • When benchmarking ROI, ROAS, CPA, CPL, and CAC across campaigns.
  • When preparing executive reports with ready-to-use templates.
  • When validating A/B tests with structured documentation and analysis.

Quick Start

  1. Step 1: Prepare campaign_data.json with journeys, funnel, and campaigns sections as shown in SKILL.md.
  2. Step 2: Run the tools: python scripts/attribution_analyzer.py campaign_data.json (optionally --model time-decay and --format json).
  3. Step 3: Review the output in text or json for integration into dashboards.

Best Practices

  • Use the provided JSON inputs (campaigns, journeys, funnel) and ensure timestamps are in ISO 8601.
  • Run all five attribution models to compare credit allocation, or select a model that fits your attribution strategy.
  • Use the two output formats (text and json) to support human reviews and pipeline integration.
  • Regularly benchmark ROI metrics (ROI, ROAS, CPA, CPL, CAC) and flag underperformance.
  • Leverage A/B test templates to document hypotheses and results alongside analytics.

Example Use Cases

  • Analyzing a multi-channel product launch to identify top-credit channels.
  • Identifying a funnel bottleneck between 'Interest' and 'Consideration' stages.
  • Calculating ROI and CAC for a seasonal email campaign across channels.
  • Comparing paid social vs. organic search performance with channel normalization.
  • Documenting an A/B test analysis with attribution and funnel results.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers