Amazon Ads Data & Optimization - Take Home
Assignment
Objective
Build a small Python service that simulates pulling Amazon Sponsored Products keyword
performance data, performs data transformations, and applies bid optimization logic.
Part 1: Data Handling & Aggregation
• Load provided JSON performance data.
• Normalize into a Pandas DataFrame.
• Aggregate by campaignId, adGroupId, and keywordId.
• Compute CTR, CPC, CVR, ACoS, and ROAS.
• Handle edge cases (zero clicks, zero sales, missing values).
Sample Input Structure
[
{
"campaignId": "123",
"adGroupId": "111",
"keywordId": "9001",
"keywordText": "vitamin c serum",
"matchType": "EXACT",
"impressions": 10000,
"clicks": 120,
"cost": 240.0,
"sales": 800.0,
"orders": 20,
"date": "2026-01-10"
}
]
Part 2: Bid Optimization Logic
• Target ACoS = 25%.
• If sales = 0 and clicks ≥ 20 → decrease bid by 20%.
• If ACoS > 1.5 × target → decrease bid by 15%.
• If ACoS < 0.7 × target → increase bid by 10%.
• Otherwise → no change.
• Enforce min bid = 0.2 and max bid = 5.0.
Expected Output Format
[
{
"keywordId": "9001",
"oldBid": 1.2,
"newBid": 1.02,
"reason": "High ACoS"
}
]
Part 3: Deduplication & Data Freshness
• Simulate duplicate rows for the same (keywordId, date).
• Keep only the latest record per (keywordId, date).
• Explain how to enforce uniqueness in PostgreSQL.
• Explain how to prevent duplicate inserts at the application layer.
Part 4: Architecture Questions (Written)
• How would you handle Amazon Ads API rate limits?
• How would you design retries and backoff?
• How would you store and refresh OAuth tokens securely?
• How would you structure this inside a Django project?
• How would you implement a rolling 30-day window (excluding last 2 days)?
Submission Requirements
• GitHub repository link.
• Clear README with setup instructions.
• Well-structured and modular code.
• Include at least 3 unit tests.
Evaluation Criteria
• Code quality and structure.
• Correct metric calculations.
• Edge case handling.
• Optimization logic clarity.
• Architectural thinking.