101
0/304
Loading content...
A marketing analytics pipeline records user reactions to shown ads.
Table: ads
Allowed action values:
Metric definition per ad_id:
Important behavior:
Task: Return ctr for every ad_id present in ads.
Output requirements:
Supported submission environments:
ads:
| ad_id | user_id | action |
|-------|---------|---------|
| 1 | 101 | Clicked |
| 1 | 102 | Viewed |
| 1 | 103 | Clicked |
| 2 | 201 | Viewed |
| 2 | 202 | Ignored |
| 3 | 301 | Ignored |
| 3 | 302 | Ignored |[
{"ad_id":1,"ctr":66.67},
{"ad_id":2,"ctr":0.0},
{"ad_id":3,"ctr":0.0}
]Ad 1 has 2 clicks and 1 view, so CTR is 66.67. Ad 2 has 0 clicks and 1 view, so CTR is 0.00. Ad 3 has no clicks/views, so denominator is zero and CTR is 0.00.
ads:
| ad_id | user_id | action |
|-------|---------|---------|
| 10 | 1 | Clicked |
| 10 | 2 | Viewed |
| 11 | 1 | Clicked |
| 11 | 3 | Viewed |
| 12 | 5 | Clicked |
| 12 | 6 | Clicked |
| 12 | 7 | Viewed |[
{"ad_id":12,"ctr":66.67},
{"ad_id":10,"ctr":50.0},
{"ad_id":11,"ctr":50.0}
]Ads 10 and 11 tie at 50.00, so ad_id ascending order breaks the tie. Ad 12 has 2 clicks out of 3 engaged actions, so CTR is 66.67.
ads:
| ad_id | user_id | action |
|-------|---------|---------|
| 99 | 10 | Viewed |
| 99 | 11 | Viewed |
| 99 | 12 | Ignored |
| 77 | 10 | Clicked |
| 77 | 11 | Ignored |
| 77 | 12 | Clicked |[
{"ad_id":77,"ctr":100.0},
{"ad_id":99,"ctr":0.0}
]Ad 77 has 2 clicks and 0 views, so CTR is 100.00. Ad 99 has 0 clicks and 2 views, so CTR is 0.00.
Constraints