campaign-analytics

2
1
Source

Analyzes campaign performance with multi-touch attribution, funnel conversion, and ROI calculation for marketing optimization

Install

mkdir -p .claude/skills/campaign-analytics && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3042" && unzip -o skill.zip -d .claude/skills/campaign-analytics && rm skill.zip

Installs to .claude/skills/campaign-analytics

About this skill

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.


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
    }
  ]
}

Input Validation

Before running scripts, verify your JSON is valid and matches the expected schema. Common errors:

  • Missing required keys (e.g., journeys, funnel.stages, campaigns) → script exits with a descriptive KeyError
  • Mismatched array lengths in funnel data (stages and counts must be the same length) → raises ValueError
  • Non-numeric monetary values in ROI data → raises TypeError

Use python -m json.tool your_file.json to validate JSON syntax before passing it to any script.


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

Typical Analysis Workflow

For a complete campaign review, run the three scripts in sequence:

# Step 1 — Attribution: understand which channels drive conversions
python scripts/attribution_analyzer.py campaign_data.json --model time-decay

# Step 2 — Funnel: identify where prospects drop off on the path to conversion
python scripts/funnel_analyzer.py funnel_data.json

# Step 3 — ROI: calculate profitability and benchmark against industry standards
python scripts/campaign_roi_calculator.py campaign_data.json

Use attribution results to identify top-performing channels, then focus funnel analysis on those channels' segments, and finally validate ROI metrics to prioritize budget reallocation.


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 -- Compare at least 3 models to triangulate channel value; no single model tells the full story.
  2. Set appropriate lookback windows -- Match your time-decay half-life to your average sales cycle length.
  3. Segment your funnels -- Compare segments (channel, cohort, geography) to identify performance drivers.
  4. Benchmark against your own history first -- Industry benchmarks provide context, but 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 -- Scripts provide descriptive metrics only; p-value calculations require external tools.
  • Standard library only -- No advanced statistical 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 -- 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.

Related Skills

  • analytics-tracking: For setting up tracking. NOT for analyzing data (that's this skill).
  • ab-test-setup: For designing experiments to test what analytics reveals.
  • marketing-ops: For routing insights to the right execution skill.
  • paid-ads: For optimizing ad spend based on analytics findings.

senior-architect

alirezarezvani

Comprehensive software architecture skill for designing scalable, maintainable systems using ReactJS, NextJS, NodeJS, Express, React Native, Swift, Kotlin, Flutter, Postgres, GraphQL, Go, Python. Includes architecture diagram generation, system design patterns, tech stack decision frameworks, and dependency analysis. Use when designing system architecture, making technical decisions, creating architecture diagrams, evaluating trade-offs, or defining integration patterns.

444257

finance-skills

alirezarezvani

Production-ready financial analyst skill with ratio analysis, DCF valuation, budget variance analysis, and rolling forecast construction. 4 Python tools (all stdlib-only). Works with Claude Code, Codex CLI, and OpenClaw.

12071

content-creator

alirezarezvani

Create SEO-optimized marketing content with consistent brand voice. Includes brand voice analyzer, SEO optimizer, content frameworks, and social media templates. Use when writing blog posts, creating social media content, analyzing brand voice, optimizing SEO, planning content calendars, or when user mentions content creation, brand voice, SEO optimization, social media marketing, or content strategy.

14134

ad-creative

alirezarezvani

When the user needs to generate, iterate, or scale ad creative for paid advertising. Use when they say 'write ad copy,' 'generate headlines,' 'create ad variations,' 'bulk creative,' 'iterate on ads,' 'ad copy validation,' 'RSA headlines,' 'Meta ad copy,' 'LinkedIn ad,' or 'creative testing.' This is pure creative production — distinct from paid-ads (campaign strategy). Use ad-creative when you need the copy, not the campaign plan.

8132

cold-email

alirezarezvani

When the user wants to write, improve, or build a sequence of B2B cold outreach emails to prospects who haven't asked to hear from them. Use when the user mentions 'cold email,' 'cold outreach,' 'prospecting emails,' 'SDR emails,' 'sales emails,' 'first touch email,' 'follow-up sequence,' or 'email prospecting.' Also use when they share an email draft that sounds too sales-y and needs to be humanized. Distinct from email-sequence (lifecycle/nurture to opted-in subscribers) — this is unsolicited outreach to new prospects. NOT for lifecycle emails, newsletters, or drip campaigns (use email-sequence).

6726

content-trend-researcher

alirezarezvani

Advanced content and topic research skill that analyzes trends across Google Analytics, Google Trends, Substack, Medium, Reddit, LinkedIn, X, blogs, podcasts, and YouTube to generate data-driven article outlines based on user intent analysis

12325

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,6871,430

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,2711,336

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,5441,153

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,359809

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,266728

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,495685