A comprehensive data analysis project examining digital marketing campaign performance using real Facebook Ads data. This study focuses on cost optimization strategies by identifying inefficient ad spending patterns and high-performing audience segments through statistical analysis and data visualization.
This analysis examines 1,143 observations from XYZ company's Facebook advertising campaigns to identify cost optimization opportunities. Without revenue data available, the project treats the problem as a cost minimization exercise, aiming to cut underperforming campaigns while scaling winning patterns.
Ideally, we would have revenue return data to calculate actual ROI. However, this analysis approaches the problem from a cost optimization perspective:
- Identify and cut campaigns with high relative spending and low performance
- Discover demographic and segmentation patterns that work
- Recommend adjustments to maximize investment efficiency
- π° $10,442 in immediate savings identified by pausing 87 "zombie" ads (ads with zero conversions)
- π 30-34 age range shows statistically significant superior performance (p < 0.05, Bonferroni corrected)
β οΈ Campaign 1178 has 2x worse CPA than other campaigns due to poor audience segmentation- π« 40-49 age group generates high costs with minimal conversion rates
- β Specific interest codes (29, 16, 10, 15, 19, 26, 64, 63, 27) perform well when properly segmented
- π₯ Statistical evidence of gender CPA differences requiring consideration in budget allocation
- R (4.x) - Main analysis language
- tidyverse - Data manipulation and transformation
- ggplot2 - Data visualization and custom plotting
- skimr - Statistical summaries and data profiling
- DataExplorer - Automated exploratory data analysis
- gridExtra - Multi-plot arrangements
- scales - Scale formatting for visualizations
βββ data/
β βββ KAG_conversion_data.csv
βββ marketing_campaign_analysis.R
βββ marketing_campaign_analysis.pt-BR.R
βββ README.md
βββ README.pt-BR.md
- Campaign distribution and volume analysis
- Demographic patterns (age, gender)
- Data quality assessment
- Missing value analysis
- CTR (Click-Through Rate): Click rate relative to impressions
- CPC (Cost Per Click): Average cost per click
- CPA (Cost Per Acquisition): Cost per completed sale
- Conversion funnel analysis by campaign
Custom framework classifying each ad into:
- β Star (Cheap): CPA below $40 (base average)
- π Zombie (Spends and doesn't sell): Zero conversions, spent > $50
β οΈ Expensive (Needs Optimization): CPA above $40- π§ͺ In Test: Low relative spending
- Pairwise proportion tests with Bonferroni correction for age groups
- Kruskal-Wallis test for CPA differences by gender
- Hypothesis testing at Ξ± = 0.05 significance level
- Problem diagnosis (demographic dispersion, zombie ads, poor segmentation)
- High-performance profile identification
- Short and medium-term action plans
- Expected impact quantification
Source: Kaggle - Sales Conversion Optimization
Size: 1,143 observations Γ 11 variables
Variables:
ad_id: Unique identifier for each adxyz_campaign_id: XYZ company campaign IDfb_campaign_id: Facebook campaign tracking IDage: Target audience age rangegender: Target audience gender (M/F)interest: Interest category codeImpressions: Number of times ad was displayedClicks: Number of clicks receivedSpent: Amount invested ($)Total_Conversion: Total leads generatedApproved_Conversion: Total sales completed
# Install required packages
install.packages(c(
"readr",
"tidyverse",
"ggplot2",
"skimr",
"DataExplorer",
"gridExtra",
"scales"
))# Clone the repository
git clone https://github.com/yourusername/facebook-ads-analysis.git
cd facebook-ads-analysis
# Open R or RStudio and run
source("marketing_campaign_analysis.R")The script will generate:
- Statistical summaries and data quality reports
- Multiple visualization plots (funnels, heatmaps, scatter plots)
- Performance metrics by campaign
- Ad classification results
- Statistical test outputs
- β Pause 87 zombie ads β $10,442 immediate savings
- β Top 10 zombies alone represent 30% of total waste
- π― Exclude 40-49 age range from Campaign 1178
- π― This demographic shows high cost with minimal conversion
- π Reallocate budget to 30-34 age range with proven performance
- π Create new ad sets using high-performing interests (29, 16, 10, 15, 19, 26, 64, 63, 27)
- π Restrict to 30-34 age range exclusively
- π Weekly monitoring of "Expensive" classified ads
- π $50 test spending limit before zombie classification
- π Quarterly review cycles for new interest identification
The analysis includes professional visualizations such as:
- Conversion Funnel Charts: Visual representation of campaign performance from impressions to sales
- Gender Distribution Heatmaps: Demographic patterns across campaigns and age ranges
- Interest Performance Matrices: Bubble charts showing CPA vs sales volume
- Star vs Zombie Comparison: Demographic profile differences between high and low performers
- Common Interest Analysis: Quadrant plots identifying segmentation optimization opportunities
| Campaign | Ads Run | Investment | CPA | LeadβSale Rate |
|---|---|---|---|---|
| 916 | Low | Low | Lowest | Best |
| 936 | Medium | Medium | Medium | Medium |
| 1178 | Highest | Highest | 2x worse | Worst |
High Performers (Stars):
- Age: 30-34 years (statistically significant, p < 0.05)
- Gender: Balanced with slight male focus
- Interests: Codes 29, 16, 10, 15, 19, 26, 64, 63, 27
Low Performers (Zombies):
- Age: 40-49 years (poor conversion rate)
- Same interest codes but different demographic
- Problem is segmentation, not interest quality
Age Range Conversion Rates (Pairwise Proportion Test)
- 30-34 vs 35-39: p < 0.05 β
- 30-34 vs 40-44: p < 0.01 ββ
- 30-34 vs 45-49: p < 0.001 βββ
-
Same interests, different results: Interest codes 29, 16, 10, 15 appear in both top-performing and worst-performing ads. The difference? Age segmentation.
-
Zombie concentration: Campaign 1178's poor performance is driven by a large number of non-converting ads that should have been paused earlier.
-
Statistical validation matters: Initial observations were confirmed through rigorous hypothesis testing, providing confidence in recommendations.
-
Cost vs Revenue: Without revenue data, we focus on cost minimization. Future analyses should incorporate revenue tracking for complete ROI assessment.