A comprehensive Python-based analytics tool for evaluating marketing campaign performance, identifying optimization opportunities, and making data-driven budget allocation decisions.
- Business Use Case
- Key Metrics Explained
- Getting Started
- Project Structure
- How Teams Use This Analysis
- Understanding the Output
- Sample Insights from Analysis
- Customization
- Advanced Usage
- Contributing
- License
- Support
- Learning Resources
- Roadmap
- Star This Repository
Marketing teams spend significant budgets across multiple channels (social media, search engines, email, etc.) without always knowing which campaigns deliver the best return on investment. This analyzer helps:
- Marketing Managers: Identify which campaigns to scale up or shut down
- Growth Teams: Optimize budget allocation across channels
- Executives: Understand overall marketing efficiency and ROI
- Data Analysts: Generate actionable insights from campaign data
- Budget Waste: Continuing to fund underperforming campaigns
- Missed Opportunities: Not scaling campaigns with strong ROI
- Poor Visibility: Lacking clear metrics to compare campaign performance
- Data Overload: Having data but no actionable recommendations
The analyzer now provides specific, actionable budget recommendations:
- Identifies bottom 20% ROI campaigns to reduce by 50%
- Calculates exact dollar amounts to reallocate to top 20% performers
- Projects impact: additional conversions, ROI boost, CPA savings
- Visualizes before/after budget allocation with impact metrics
Example Output: "Shift $6,050 from 3 underperformers to 3 top campaigns β +876 conversions (+18% increase), +523% ROI improvement"
CTR = (Clicks / Impressions) Γ 100
- What it measures: How compelling your ad is to your target audience
- Good benchmark: 2-5% (varies by industry and channel)
- Use case: Evaluating ad creative effectiveness
- Optimization: Low CTR β Test new headlines, images, or targeting
CPC = Total Spend / Total Clicks
- What it measures: Average cost to get someone to click your ad
- Good benchmark: $1-3 for most industries
- Use case: Evaluating traffic acquisition efficiency
- Optimization: High CPC β Improve Quality Score, refine targeting, test new keywords
CPA = Total Spend / Total Conversions
- What it measures: Average cost to acquire one customer/conversion
- Good benchmark: Should be lower than your Customer Lifetime Value (CLV)
- Use case: Determining campaign profitability
- Optimization: High CPA β Optimize landing pages, improve audience targeting
Conversion Rate = (Conversions / Clicks) Γ 100
- What it measures: Percentage of visitors who complete desired action
- Good benchmark: 2-10% (varies by industry)
- Use case: Evaluating landing page and offer effectiveness
- Optimization: Low conversion β A/B test landing pages, simplify checkout, improve messaging
ROI = ((Revenue - Spend) / Spend) Γ 100
- What it measures: Profitability of the campaign
- Good benchmark: Positive ROI (>0%) means profitable
- Use case: Overall campaign success measurement
- Optimization: Negative ROI β Pause campaign or implement all above optimizations
Python 3.7+
pip (Python package manager)- Clone the repository:
git clone https://github.com/yourusername/marketing-performance-analyzer.git
cd marketing-performance-analyzer- Install required packages:
pip install pandas matplotlib- Run the analyzer:
python analyzer.py- View the results:
- Console output: Performance summary and recommendations
campaign_performance_dashboard.png: Visual dashboardcampaign_analysis_results.csv: Detailed metrics for all campaigns
marketing-performance-analyzer/
β
βββ sample_data.csv # Sample campaign data (15 campaigns)
βββ analyzer.py # Main analysis script
βββ README.md # This file
β
βββ Generated Outputs:
β βββ campaign_analysis_results.csv # Detailed results with rankings
β βββ campaign_performance_dashboard.png # Visual performance dashboard (4 charts)
β βββ budget_reallocation_strategy.png # Budget reallocation visualization (2 charts)
- Daily/Weekly: Monitor campaign performance trends
- Monthly: Review ROI rankings and adjust budgets
- Quarterly: Identify winning strategies to replicate
Example Decision: "Instagram Influencer campaign has 186% ROI. Let's increase its budget by 50% next month."
- Channel Optimization: Compare performance across different platforms
- A/B Testing: Track which variations perform better
- Budget Reallocation: Move spend from low to high ROI campaigns
Example Decision: "Move 30% of budget from Brand Awareness (ROI: 100%) to TikTok Video Ads (ROI: 193%)."
- Efficiency Reporting: Overall marketing spend effectiveness
- Budget Planning: Data-driven budget requests
- Performance Benchmarking: Compare to industry standards
Example Decision: "Current average CPA is $11.23. Target is $9.50. Need to optimize bottom 5 campaigns."
- Deep Dive Analysis: Investigate patterns in high/low performers
- Predictive Modeling: Use historical data to forecast performance
- Attribution Analysis: Understand which campaigns drive conversions
Example Insight: "Campaigns with CTR > 4% and conversion rate > 6% consistently achieve ROI > 150%."
- Shows all campaigns ranked by ROI
- Includes all key metrics for quick comparison
- Identify winners and losers at a glance
- Top Performers: Campaigns to scale up
- Underperformers: Campaigns to optimize or pause
- High Traffic, Low Conversion: Landing page issues
- Budget Allocation Insights: Overall spend efficiency
- Quick Wins: Low-hanging fruit opportunities
- Specific dollar amounts to shift from bottom 20% to top 20% ROI campaigns
- Detailed breakdown showing current vs. proposed budgets for each campaign
- Projected impact: Additional conversions, ROI improvement, and CPA savings
- Example Output:
TOTAL TO REALLOCATE: $6,050.00 β’ Cut 50% from: YouTube_PreRoll, LinkedIn_B2B_Outreach, Brand_Awareness_Q3 β’ Add to: Email_Newsletter_Oct (+$913), Retargeting_Campaign (+$1,598) PROJECTED IMPACT: β’ +876 conversions (+18.0% increase) β’ ROI boost: +523.5% β’ $15.65 CPA savings per conversion
- ROI Comparison: Bar chart showing profitability
- Cost Efficiency Matrix: Scatter plot of CPA vs Conversion Rate
- Spend vs Conversions: Budget allocation effectiveness
- CTR vs Conversion Rate: Funnel performance comparison
- Before & After Chart: Visual comparison of current vs. proposed budgets
- Performance Metrics Comparison: ROI, CPA, and conversion rate differences
- Impact Summary: Key projected outcomes highlighted
- Red bars = budget cuts, Green bars = budget increases
β
TOP PERFORMERS (Scale Up):
1. Instagram_Influencer
β ROI: 186.67% | CPA: $8.33 | Conversion Rate: 6.0%
β Recommendation: Increase budget by 25-50% to maximize returns
β οΈ UNDERPERFORMERS (Optimize or Pause):
15. YouTube_PreRoll
β ROI: 3.92% | CPA: $18.75 | Conversion Rate: 4.0%
β Low Conversion Rate: Optimize landing page or audience targeting
π― HIGH TRAFFIC, LOW CONVERSION (Landing Page Optimization Needed):
β’ Social_Media_Boost
β CTR: 4.0% (Good) | Conversion Rate: 5.0% (Needs Work)
β Recommendation: A/B test landing pages, improve load speed, clarify CTA
π° BUDGET REALLOCATION STRATEGY:
TOTAL TO REALLOCATE: $6,050.00
π Cut 50% from bottom 20%:
β’ YouTube_PreRoll: $5,100 β $2,550 (-$2,550)
β’ LinkedIn_B2B_Outreach: $2,800 β $1,400 (-$1,400)
β’ Brand_Awareness_Q3: $4,200 β $2,100 (-$2,100)
π Add to top 20%:
β’ Email_Newsletter_Oct: $800 β $1,713 (+$913)
β’ Retargeting_Campaign: $1,400 β $2,998 (+$1,598)
β’ Black_Friday_Early: $3,100 β $6,639 (+$3,539)
π PROJECTED IMPACT:
β +876 conversions (+18.0% increase)
β ROI boost: +523.5%
β $15.65 CPA savings per conversion
-
Prepare your CSV with these columns:
campaign_name: Name of the campaignimpressions: Number of ad viewsclicks: Number of clicks on adsconversions: Number of successful conversionsspend: Total amount spent (in dollars)
-
Update the analyzer (optional):
- Modify
avg_order_valueincalculate_metrics()function (line 65) to match your business - Adjust benchmark thresholds in recommendations
- Customize visualization colors/style
- Modify
-
Run the analysis:
python analyzer.py# Example: Load data from your database
import pandas as pd
from analyzer import calculate_metrics, rank_campaigns
# Connect to your database
df = pd.read_sql("SELECT * FROM campaigns WHERE date >= '2024-01-01'", conn)
# Run analysis
df_metrics = calculate_metrics(df)
df_ranked = rank_campaigns(df_metrics)
# Generate insights
df_ranked.to_csv('monthly_report.csv', index=False)# Add to cron job for monthly automation
0 9 1 * * cd /path/to/analyzer && python analyzer.py && mail -s "Monthly Campaign Report" team@company.com < campaign_analysis_results.csvContributions are welcome! Here's how you can help:
- Add new metrics: ROAS, LTV/CAC ratio, attribution models
- Improve visualizations: Interactive dashboards, more chart types
- Add data sources: Connect to Google Analytics, Facebook Ads API
- Enhance recommendations: ML-based predictive insights
1. Fork the repository
2. Create your feature branch: git checkout -b feature/AmazingFeature
3. Commit your changes: git commit -m 'Add some AmazingFeature'
4. Push to the branch: git push origin feature/AmazingFeature
5. Open a Pull RequestThis project is licensed under the MIT License - see the LICENSE file for details.
Questions or Issues?
- Open an issue on GitHub
- Contact: mail@ericjoye.com
To get the most out of this tool, check out:
- Google Analytics Academy
- Digital Marketing Metrics Guide
- A/B Testing Best Practices
- ROI Calculation Methods
- β Budget reallocation suggestions with specific dollar amounts
- β Projected impact calculations (conversions, ROI, CPA improvements)
- β Before/After visualization showing budget shifts
- API integrations (Google Ads, Facebook Ads, LinkedIn Ads)
- Real-time dashboard with auto-refresh
- Predictive analytics for campaign forecasting
- Multi-touch attribution modeling
- Automated email reports
- Cohort analysis and customer segmentation
- Cost anomaly detection and alerts
If you find this tool useful, please star the repository! It helps others discover it.
*Built with β€οΈ
Last Updated: January 2026