name: Marketing Campaign ROI Analysis
category: Marketing & Growth
description: Multi-channel marketing ROI analysis with customer acquisition modeling, lifetime value optimization, and ARR-based budget allocation
version: 2.0.0
tags: [marketing, roi, customer-acquisition, digital-marketing, campaign-optimization]

parameters:
  - key: annualRecurringRevenue
    label: Company ARR ($)
    type: number
    default: 3600000
    min: 250000
    max: 50000000
    step: 100000
    description: Annual recurring revenue for marketing budget planning

  - key: marketingBudgetPercent
    label: Marketing Budget (% of ARR)
    type: number
    default: 15.0
    min: 5.0
    max: 30.0
    step: 0.5
    description: "Marketing spend as percentage of ARR (typical B2B: 8-15%, B2C: 15-25%)"

  - key: campaignDuration
    label: Campaign Duration (months)
    type: number
    default: 6
    min: 1
    max: 18
    step: 1
    description: Length of marketing campaign for ROI analysis

  - key: targetMarket
    label: Target Market
    type: select
    default: b2b-smb
    options: [b2c-mass, b2c-premium, b2b-smb, b2b-enterprise, marketplace]
    description: Primary target market affecting acquisition costs and conversion rates

  - key: acquisitionModel
    label: Acquisition Model
    type: select
    default: multi-channel
    options: [digital-only, traditional-only, multi-channel, influencer-led, content-driven]
    description: Primary customer acquisition approach

  - key: averageOrderValue
    label: Average Order Value ($)
    type: number
    default: 275
    min: 15
    max: 50000
    step: 25
    description: Average customer transaction value

  - key: customerLifetimeValue
    label: Customer Lifetime Value ($)
    type: number
    default: 1850
    min: 50
    max: 100000
    step: 50
    description: Projected total value per acquired customer

  - key: seasonalityFactor
    label: Campaign Seasonality
    type: select
    default: neutral
    options: [off-peak, neutral, high-demand, holiday-premium]
    description: Seasonal timing impact on campaign performance

  - key: competitiveEnvironment
    label: Competitive Environment
    type: select
    default: moderate
    options: [low-competition, moderate, high-competition, saturated-market]
    description: Market competition level affecting acquisition costs

groups:
  - name: Budget & Timeline
    description: ARR-based budget allocation and campaign duration
    parameters: [annualRecurringRevenue, marketingBudgetPercent, campaignDuration]
    
  - name: Market Context
    description: Target audience and competitive landscape
    parameters: [targetMarket, competitiveEnvironment, seasonalityFactor]
    
  - name: Customer Economics
    description: Revenue metrics and acquisition strategy
    parameters: [averageOrderValue, customerLifetimeValue, acquisitionModel]

outputs:
  - key: totalCampaignBudget
    label: Total Campaign Budget ($)
    description: Total marketing spend allocated to campaign

  - key: totalCustomersAcquired
    label: Customers Acquired
    description: Total new customers acquired during campaign

  - key: blendedCAC
    label: Blended CAC ($)
    description: Average cost to acquire each customer across all channels

  - key: campaignROI
    label: Campaign ROI (%)
    description: Return on investment for campaign period

  - key: lifetimeROI
    label: Lifetime Value ROI (%)
    description: ROI considering full customer lifetime value

  - key: paybackPeriod
    label: Customer Payback (months)
    description: Time to recover customer acquisition investment

  - key: organicMultiplier
    label: Organic Growth Multiplier
    description: Amplification factor from word-of-mouth and viral growth

  - key: brandImpactScore
    label: Brand Impact Score
    description: Long-term brand awareness and recognition improvement

simulation:
  logic: |
    // Calculate campaign budget from ARR allocation
    const annualMarketingBudget = annualRecurringRevenue * (marketingBudgetPercent / 100)
    const totalCampaignBudget = (annualMarketingBudget / 12) * campaignDuration
    
    // Market segment acquisition characteristics
    const marketMetrics = {
      'b2c-mass': { 
        baseCPC: 1.20, 
        conversionRate: 0.025, 
        organicFactor: 1.4, 
        brandImpact: 0.6 
      },
      'b2c-premium': { 
        baseCPC: 3.80, 
        conversionRate: 0.018, 
        organicFactor: 1.2, 
        brandImpact: 0.9 
      },
      'b2b-smb': { 
        baseCPC: 4.50, 
        conversionRate: 0.012, 
        organicFactor: 1.1, 
        brandImpact: 0.7 
      },
      'b2b-enterprise': { 
        baseCPC: 18.00, 
        conversionRate: 0.006, 
        organicFactor: 0.95, 
        brandImpact: 1.1 
      },
      'marketplace': { 
        baseCPC: 2.50, 
        conversionRate: 0.035, 
        organicFactor: 1.3, 
        brandImpact: 0.5 
      }
    }
    
    // Acquisition model efficiency and cost factors
    const acquisitionEfficiency = {
      'digital-only': { costEfficiency: 0.8, reach: 1.2, brandBuilding: 0.6 },
      'traditional-only': { costEfficiency: 1.4, reach: 0.8, brandBuilding: 1.0 },
      'multi-channel': { costEfficiency: 1.0, reach: 1.0, brandBuilding: 0.8 },
      'influencer-led': { costEfficiency: 0.9, reach: 0.9, brandBuilding: 1.2 },
      'content-driven': { costEfficiency: 0.7, reach: 0.7, brandBuilding: 1.4 }
    }
    
    // Seasonality impact on performance
    const seasonalMultipliers = {
      'off-peak': { cost: 0.7, conversion: 0.8, competition: 0.6 },
      'neutral': { cost: 1.0, conversion: 1.0, competition: 1.0 },
      'high-demand': { cost: 1.3, conversion: 1.2, competition: 1.4 },
      'holiday-premium': { cost: 1.8, conversion: 1.1, competition: 1.8 }
    }
    
    // Competitive environment impact
    const competitiveFactors = {
      'low-competition': { costMultiplier: 0.6, conversionBonus: 1.3 },
      'moderate': { costMultiplier: 1.0, conversionBonus: 1.0 },
      'high-competition': { costMultiplier: 1.5, conversionBonus: 0.8 },
      'saturated-market': { costMultiplier: 2.2, conversionBonus: 0.6 }
    }
    
    // Extract factors for current configuration
    const market = marketMetrics[targetMarket]
    const acquisition = acquisitionEfficiency[acquisitionModel]
    const seasonal = seasonalMultipliers[seasonalityFactor]
    const competition = competitiveFactors[competitiveEnvironment]
    
    // Calculate effective acquisition metrics
    const effectiveCPC = market.baseCPC * 
                        acquisition.costEfficiency * 
                        seasonal.cost * 
                        competition.costMultiplier * 
                        (0.8 + random() * 0.4)  // ±20% execution variance
    
    const effectiveConversionRate = market.conversionRate * 
                                   seasonal.conversion * 
                                   competition.conversionBonus * 
                                   (0.8 + random() * 0.4)
    
    // Channel mix modeling (simplified to blended metrics)
    const totalClicks = totalCampaignBudget / effectiveCPC
    const directCustomersAcquired = totalClicks * effectiveConversionRate
    
    // Organic amplification from paid efforts
    const organicMultiplier = market.organicFactor * acquisition.reach * (0.9 + random() * 0.2)
    const organicCustomersAcquired = directCustomersAcquired * (organicMultiplier - 1)
    const totalCustomersAcquired = directCustomersAcquired + organicCustomersAcquired
    
    // Cost calculations
    const blendedCAC = totalCustomersAcquired > 0 ? totalCampaignBudget / totalCustomersAcquired : 0
    
    // ROI calculations
    const immediateRevenue = totalCustomersAcquired * averageOrderValue
    const lifetimeRevenue = totalCustomersAcquired * customerLifetimeValue
    
    const campaignROI = totalCampaignBudget > 0 ? 
                       ((immediateRevenue - totalCampaignBudget) / totalCampaignBudget) * 100 : 0
    
    const lifetimeROI = totalCampaignBudget > 0 ? 
                       ((lifetimeRevenue - totalCampaignBudget) / totalCampaignBudget) * 100 : 0
    
    // Payback period calculation
    const monthlyRevenuePerCustomer = averageOrderValue * 0.8  // Assuming 80% repeat purchase rate
    const paybackPeriod = monthlyRevenuePerCustomer > 0 ? blendedCAC / monthlyRevenuePerCustomer : 999
    
    // Brand impact scoring (0-10 scale)
    const brandImpactScore = market.brandImpact * 
                           acquisition.brandBuilding * 
                           (campaignDuration / 6) *  // Longer campaigns = more brand impact
                           Math.min(totalCampaignBudget / 50000, 2) *  // Budget impact (capped at 2x)
                           (0.8 + random() * 0.4) * 10
    
    return {
      totalCampaignBudget: Math.round(totalCampaignBudget),
      totalCustomersAcquired: Math.round(totalCustomersAcquired),
      blendedCAC: Math.round(blendedCAC * 100) / 100,
      campaignROI: Math.round(campaignROI * 10) / 10,
      lifetimeROI: Math.round(lifetimeROI * 10) / 10,
      paybackPeriod: Math.min(Math.round(paybackPeriod * 10) / 10, 99.9),
      organicMultiplier: Math.round(organicMultiplier * 100) / 100,
      brandImpactScore: Math.min(Math.round(brandImpactScore * 10) / 10, 10.0)
    }