Break the problem into stages: first filter and deduplicate sessions, then compute daily visibility share per shop, then average over the 7-day window handling zero-session days, and finally rank with CTR as tiebreaker. Use CTEs to modularize the query and ensure clarity. Explicitly state assumptions about visibility share definition and bot detection.
Pro tip: Clarify with the interviewer whether 'visibility share' is per session or per impression, and confirm how to handle days with zero eligible sessions—whether to treat as 0 or exclude from average. This shows attention to metric definition and edge cases.
Filter to US non-bot traffic and deduplicate sessions by taking the first or last event per session ID. Ensure only eligible sessions are considered.
For each shop and each day in the 7-day window, calculate visibility share as the sum of visibility-weighted impressions divided by total impressions, using deduplicated sessions.
Left join a date spine to shops to include all days. For days with no sessions, set visibility share to 0 (or NULL) and decide whether to include in the average.
Compute the average daily visibility share per shop over the 7 days. Rank shops by this average descending, using CTR (on deduplicated impressions) as tiebreaker, and select top 3.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.