{"id":25128220,"url":"https://github.com/mnitin-reddy/a-b-testing-and-regression-analysis-for-ad-performance-optimization","last_synced_at":"2026-04-04T22:34:22.791Z","repository":{"id":267939198,"uuid":"902784080","full_name":"MNitin-Reddy/A-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization","owner":"MNitin-Reddy","description":"Analyzed the performance of Facebook and AdWords ads using A/B testing and regression analysis to identify trends, correlations, and cost-effectiveness. Key insights included distribution of clicks and conversions, monthly trends, and cost-per-conversion analysis to optimize ROI.","archived":false,"fork":false,"pushed_at":"2024-12-17T06:02:59.000Z","size":1395,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T11:44:02.477Z","etag":null,"topics":["abtesting","data-science","hypothesis-testing","machine-learning","matplotlib","numpy","pandas","scikit-learn","scipy","seaborn","statsmodels"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MNitin-Reddy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-13T09:05:26.000Z","updated_at":"2024-12-17T07:16:42.000Z","dependencies_parsed_at":"2024-12-13T11:42:20.035Z","dependency_job_id":null,"html_url":"https://github.com/MNitin-Reddy/A-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization","commit_stats":null,"previous_names":["mnitin-reddy/a-b-testing","mnitin-reddy/a-b-testing-and-regression-analysis-for-ad-performance-optimization"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MNitin-Reddy%2FA-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MNitin-Reddy%2FA-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MNitin-Reddy%2FA-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MNitin-Reddy%2FA-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MNitin-Reddy","download_url":"https://codeload.github.com/MNitin-Reddy/A-B-Testing-and-Regression-Analysis-for-Ad-Performance-Optimization/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246894946,"owners_count":20851181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abtesting","data-science","hypothesis-testing","machine-learning","matplotlib","numpy","pandas","scikit-learn","scipy","seaborn","statsmodels"],"created_at":"2025-02-08T11:44:08.366Z","updated_at":"2025-12-30T23:10:40.146Z","avatar_url":"https://github.com/MNitin-Reddy.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A/B Testing and Regression Analysis for Ad Performance Optimization 📊\r\n\r\n## Business Problem\r\nAs a marketing agency, our objective is to **maximize the return on investment (ROI)** for our clients' advertising campaigns. We conducted two ad campaigns:\r\n1. **Facebook Ads**  \r\n2. **AdWords Ads**\r\n\r\nWe aim to determine which platform performs better in terms of:\r\n- Clicks  \r\n- Conversions  \r\n- Cost-effectiveness  \r\n\r\nThe insights will help optimize resource allocation and enhance advertising strategies.\r\n\r\n---\r\n\r\n## Research Question\r\n**Which ad platform is more effective in terms of conversions, clicks, and overall cost-effectiveness?**\r\n\r\n---\r\n\r\n## Dataset Description\r\n\r\nThe dataset contains daily performance metrics for both Facebook and AdWords campaigns throughout **2019**. Key features include:\r\n\r\n- **Date**: Campaign date (2019-01-01 to 2019-12-31)  \r\n- **Ad Views**: Number of views on the ads  \r\n- **Ad Clicks**: Number of clicks received on the ads  \r\n- **Ad Conversions**: Number of conversions resulting from the ads  \r\n- **Cost per Ad**: Cost associated with running the ad campaigns  \r\n- **Click-Through Rate (CTR)**  \r\n- **Conversion Rate**  \r\n- **Cost per Click (CPC)**  \r\n\r\n---\r\n\r\n## Technologies Used\r\n\r\n- **Python Libraries**: pandas, numpy, matplotlib, seaborn, scipy, statsmodels, scikit-learn  \r\n- **Tools**: Jupyter Notebook  \r\n- **Statistical Techniques**: Correlation Analysis, Hypothesis Testing, Regression Modeling, Cointegration Test  \r\n\r\n---\r\n\r\n## Analysis and Insights \r\n\r\n### 1. Distribution of Clicks and Conversions\r\n\r\nThe distributions of **clicks** and **conversions** show a symmetrical shape, indicating even performance across campaigns.\r\n\r\n**Visualization:**\r\n![Facebook and AdWords Clicks/Conversions](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/Conversions%20and%20clicks%20distribution.png)\r\n\r\n---\r\n\r\n### 2. Frequency of Conversions by Categories\r\n\r\nWe categorized conversions into:\r\n- Less than 6  \r\n- 6–10  \r\n- 10–15  \r\n- More than 15  \r\n\r\n**Observations:**\r\n- Facebook had more frequent high-conversion days.\r\n- AdWords lacked days with conversions above 10.  \r\n\r\n**Visualization:**\r\n![Conversion Categories](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/Frequency%20of%20conversions.png)\r\n\r\n---\r\n\r\n### 3. Do Clicks Lead to More Conversions?\r\n\r\nWe analyzed the **correlation** between clicks and conversions for both platforms:\r\n\r\n- Facebook: **Strong Positive Correlation** (0.87)  \r\n- AdWords: **Moderate Positive Correlation** (0.45)  \r\n\r\nThis suggests Facebook is more effective in driving conversions.\r\n\r\n**Visualization:**\r\n![Scatterplot Correlation](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/Correlation.png)\r\n\r\n---\r\n\r\n### 4. Monthly Conversions Over Time\r\n\r\nConversions were analyzed across months:\r\n\r\n- Mondays and Tuesdays had the highest conversions.  \r\n- Monthly trends showed **increased conversions** over time with minor dips in February, May, and November.\r\n\r\n**Visualization:**\r\n![Monthly Conversions](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/Monthly%20Conversions.png)\r\n\r\n---\r\n\r\n### 5. Monthly Cost Per Conversion (CPC)\r\n\r\nWe analyzed the **Cost Per Conversion** to understand advertising cost-effectiveness:\r\n\r\n- **May and November** had the lowest CPC values.  \r\n- February had the **highest CPC**, indicating less cost-effectiveness.\r\n\r\n**Visualization:**\r\n![Cost Per Conversion](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/CPC.png)\r\n\r\n---\r\n\r\n### 6. Hypothesis Testing\r\n\r\n- **Hypothesis**: Facebook has more conversions than AdWords.  \r\n- **Result**:  \r\n  - Mean Conversions:  \r\n    - Facebook: **11.74**  \r\n    - AdWords: **5.98**  \r\n  - **p-value**: Extremely small (9.35e-134) → Reject the null hypothesis.  \r\n\r\n**Conclusion**: Facebook ads generate **significantly more conversions** than AdWords.\r\n\r\n---\r\n\r\n### 7. Linear Regression: Predicting Conversions from Clicks\r\n\r\nWe built a Linear Regression model for Facebook ads:\r\n\r\n- **R² Score**: 76.35%  \r\n- **Insights**: Predicting Facebook conversions based on clicks helps set realistic goals.  \r\n\r\nExample predictions:  \r\n- **For 50 clicks → ~9 conversions**  \r\n- **For 80 clicks → ~14 conversions**\r\n\r\n**Visualization:**\r\n![Linear Regression](https://github.com/MNitin-Reddy/A-B-Testing/blob/main/images/Regression%20Analysis.png)\r\n\r\n---\r\n\r\n### 8. Cointegration Test: Cost and Conversions\r\n\r\nA **cointegration test** showed a long-term equilibrium relationship between ad cost and conversions, suggesting stable budget impacts over time.\r\n\r\n---\r\n\r\n## Recommendations\r\n\r\n1. Allocate **more resources to Facebook Ads** due to their higher conversions and stronger ROI.  \r\n2. Optimize AdWords campaigns to improve click-to-conversion performance.  \r\n3. Increase ad spend during months with **lower CPC** (e.g., May, November).  \r\n4. Monitor and analyze performance during **Mondays and Tuesdays** for targeted campaigns.  \r\n\r\n---\r\n\r\n## Conclusion \r\n\r\nThe analysis demonstrates that **Facebook Ads outperform AdWords** in driving conversions. Businesses can leverage these findings to improve ad performance and ROI.\r\n\r\n---\r\n\r\n## How to Run 📥\r\n\r\n1. Clone the repository:  \r\n   ```bash\r\n   git clone https://github.com/yourusername/ad-campaign-analysis.git\r\n   cd ad-campaign-analysis\r\n   ```\r\n2. Install dependencies:  \r\n   ```bash\r\n   pip install -r requirements.txt\r\n   ```\r\n3. Run the notebook:  \r\n   ```bash\r\n   jupyter notebook notebooks/ad_campaign_analysis.ipynb\r\n   ```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnitin-reddy%2Fa-b-testing-and-regression-analysis-for-ad-performance-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnitin-reddy%2Fa-b-testing-and-regression-analysis-for-ad-performance-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnitin-reddy%2Fa-b-testing-and-regression-analysis-for-ad-performance-optimization/lists"}