Investigating Ad Traffic Volumes and User Violation Complaints
Statistics & ExperimentsModel answerLast updated
Formulate SQL logic to identify high-violation advertisers and design an analytical strategy to explain the positive correlation between ad visits and reports.
Background
During a quarterly safety audit at a digital publishing platform, the data team observed that ad campaigns accumulating higher total visit volumes also receive significantly higher absolute numbers of user reports for policy violations or poor content quality.
Management needs to know whether high-volume advertisers are inherently lower quality, or if this pattern is an artifact of raw exposure volume. Additionally, the team requires an automated SQL framework to systematically detect problematic accounts without penalizing large, compliant advertisers.
Tasks
- Define problematic advertisers: Draft a production SQL query that identifies top problematic advertisers. Outline key metrics, noise-reduction techniques, smoothing methods, and baseline comparisons that ensure small-sample outliers and massive compliant brands are handled fairly.
- Causal investigation: Detail a structured analytical plan to evaluate the positive association between ad visits and total report volume. State your hypotheses, describe potential confounders, and outline the statistical breakdowns required to determine causation.
Hints
Hint 1
Differentiate absolute report counts from report rates per impression or visit.
Hint 2
Consider statistical smoothing techniques (such as empirical Bayes) to handle low-volume advertisers with high variance.
Hint 3
Evaluate audience expansion: as ad budgets scale, targeting broadens to less aligned user segments.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Structured Response Strategy
A complete response to this operational analytics challenge requires addressing both parts:
- SQL Metric Framework: Constructing a normalized, noise-filtered, and smoothed metric definition to isolate genuinely policy-violating advertisers.
- Analytical & Causal Strategy: Deconstructing the correlation using hypothesis testing, statistical controls, and audience stratification.
Part 1: Defining a "Top Bad Advertiser" in SQL
Schema Assumptions
To write concrete SQL, we assume the following data model:
-- Core schemas
ads (ad_id, advertiser_id, ad_category, creative_type, created_at)
ad_visits (visit_id, ad_id, user_id, visit_ts, placement_type)
ad_reports (report_id, ad_id, user_id, report_reason, report_ts)
report_reviews (report_id, review_verdict, reviewed_ts) -- verdict: 'confirmed_violation', 'dismissed'
users (user_id, country, age_group, account_age_days, is_bot_flag)
Key Design Principles
- Rate Over Raw Count: Normalizing reports by visit volume (reports per 1,000 visits).
- Confirmed Violations & Unique Reporters: Filtering out unreviewed noise and preventing single-user report spam by counting distinct user-ad report pairs or verified violations.
- Volume Thresholds & Persistence: Requiring minimum exposure thresholds and multiple flagged creatives to prevent single-ad misconfigurations from penalizing an entire account.
- Empirical Bayes Rate Smoothing: Adjusting raw rates for low-traffic accounts toward the global platform average to avoid small-sample bias.
SQL Implementation
WITH time_window AS (
SELECT CURRENT_DATE - INTERVAL '30' DAY AS start_date
),
-- Aggregate visit volume per advertiser
advertiser_visits AS (
SELECT
a.advertiser_id,
COUNT(v.visit_id) AS total_visits,
COUNT(DISTINCT a.ad_id) AS total_active_ads
FROM ads a
JOIN ad_visits v ON a.ad_id = v.ad_id
WHERE v.visit_ts >= (SELECT start_date FROM time_window)
GROUP BY a.advertiser_id
),
-- Aggregate report and review metrics per advertiser
advertiser_reports AS (
SELECT
a.advertiser_id,
COUNT(DISTINCT r.user_id || '-' || r.ad_id) AS unique_user_reports,
COUNT(DISTINCT CASE WHEN rv.review_verdict = 'confirmed_violation' THEN r.report_id END) AS confirmed_violations,
COUNT(DISTINCT r.ad_id) AS reported_ad_count
FROM ads a
JOIN ad_reports r ON a.ad_id = r.ad_id
LEFT JOIN report_reviews rv ON r.report_id = rv.report_id
JOIN users u ON r.user_id = u.user_id
WHERE r.report_ts >= (SELECT start_date FROM time_window)
AND NOT u.is_bot_flag
GROUP BY a.advertiser_id
),
-- Calculate platform-wide baseline violation rate
platform_baseline AS (
SELECT
SUM(COALESCE(ar.confirmed_violations, 0)) * 1.0 / NULLIF(SUM(av.total_visits), 0) AS global_rate
FROM advertiser_visits av
LEFT JOIN advertiser_reports ar USING (advertiser_id)
),
-- Apply Empirical Bayes Smoothing (pseudo-prior of 10,000 visits)
scored_advertisers AS (
SELECT
av.advertiser_id,
av.total_visits,
av.total_active_ads,
COALESCE(ar.confirmed_violations, 0) AS confirmed_violations,
COALESCE(ar.reported_ad_count, 0) AS reported_ad_count,
-- Raw rate per 1,000 visits
(COALESCE(ar.confirmed_violations, 0) * 1000.0) / NULLIF(av.total_visits, 0) AS raw_rate_per_1k,
-- Smoothed rate per 1,000 visits
1000.0 * (COALESCE(ar.confirmed_violations, 0) + (pb.global_rate * 10000))
/ (av.total_visits + 10000) AS smoothed_rate_per_1k,
pb.global_rate * 1000.0 AS platform_rate_per_1k
FROM advertiser_visits av
LEFT JOIN advertiser_reports ar USING (advertiser_id)
CROSS JOIN platform_baseline pb
)
-- Identify top policy-violating accounts
SELECT
advertiser_id,
total_visits,
total_active_ads,
confirmed_violations,
reported_ad_count,
ROUND(raw_rate_per_1k, 3) AS raw_rate_per_1k,
ROUND(smoothed_rate_per_1k, 3) AS smoothed_rate_per_1k,
PERCENT_RANK() OVER (ORDER BY smoothed_rate_per_1k ASC) AS risk_percentile
FROM scored_advertisers
WHERE total_visits >= 10000 -- Minimum sample size threshold
AND total_active_ads >= 2 -- Prevents one-off creative anomalies
AND reported_ad_count >= 2 -- Indicates systematic behavior across creatives
AND smoothed_rate_per_1k > (3 * platform_rate_per_1k) -- Significant divergence from platform mean
ORDER BY smoothed_rate_per_1k DESC
LIMIT 50;
Part 2: Causal Investigation of the Visit-Report Correlation
Deconstructing the Mathematical Artifact
A positive correlation between total visits and total reports is mathematically expected: if each user visit carries an independent report probability $p$, then expected reports $E[\text{Reports}] = p \times \text{Visits}$.
The true analytical question is whether the report rate per visit ($p$) increases as visit scale increases ($p(V) > p$), or if $p$ remains constant.
[Raw Visit Volume] ──(+)──> [Total Reports]
│ ▲
▼ │
[Audience Expansion / Confounders] ──┘
Hypotheses Framework
| Hypothesis | Mechansim | Test Outcome |
|---|---|---|
| H0: Exposure Artifact | Constant report rate $p$. Volume linearly scales raw reports. | Report rate per 1,000 visits remains flat across visit volume deciles. |
| H1: Audience Mismatch | Scaling ad spend broadens targeting to off-target users who find content irrelevant or irritating. | Report rate increases in higher visit deciles, but disappears when controlling for targeting match degree. |
| H2: Creative Confounding | Clickbait/Sensational creatives attract both higher click volumes and higher user dissatisfaction. | Controlling for ad category and creative classification eliminates the correlation. |
| H3: Malicious Brigading / Bot Activity | High-visibility ads attract competitive flagging or automated bot reports. | High-visit report rate spikes correspond with a lower confirmed violation percentage (low precision). |
Step-by-Step Investigative Protocol
Step 1: Volume Stratification Analysis
Divide ad campaigns into deciles by visit volume and measure the per-visit report rate and confirmation rate across deciles.
WITH ad_aggregates AS (
SELECT
v.ad_id,
COUNT(v.visit_id) AS visits,
COUNT(DISTINCT r.report_id) AS total_reports,
COUNT(DISTINCT CASE WHEN rv.review_verdict = 'confirmed_violation' THEN r.report_id END) AS verified_reports
FROM ad_visits v
LEFT JOIN ad_reports r ON v.ad_id = r.ad_id
LEFT JOIN report_reviews rv ON r.report_id = rv.report_id
GROUP BY v.ad_id
),
deciled_ads AS (
SELECT
*,
NTILE(10) OVER (ORDER BY visits ASC) AS visit_decile
FROM ad_aggregates
)
SELECT
visit_decile,
MIN(visits) AS min_visits,
MAX(visits) AS max_visits,
SUM(total_reports) * 1000.0 / SUM(visits) AS report_rate_per_1k,
SUM(verified_reports) * 100.0 / NULLIF(SUM(total_reports), 0) AS confirmation_precision_pct
FROM deciled_ads
GROUP BY visit_decile
ORDER BY visit_decile;
- Outcome Interpretation:
- If
report_rate_per_1kis constant across deciles, H0 is confirmed. No further intervention is needed. - If
report_rate_per_1kincreases with deciles, move to Step 2.
- If
Step 2: Stratification by Confounders (Simpson's Paradox Check)
Calculate report rates segmented by category, creative type, and platform placement. High-volume ads may concentrate in historically sensitive categories (e.g., political ads, financial products). If the positive relationship between visit volume and report rate vanishes within each category, the macro trend is driven by category composition rather than ad volume.
Step 3: Audience Alignment & Targeting Expansion (Testing H1)
Evaluate user demography and targeting parameters:
- Compare report rates among targeted vs. non-targeted/lookalike audience exposures.
- Evaluate user account tenure: newer accounts may report ads at different rates than power users.
- If high-volume campaigns show elevated report rates predominantly among non-core targeting segments, the issue is ad platform pacing and broad targeting rather than bad intent.
Step 4: Regression Modeling with Creative Features (Testing H2)
Fit a multivariate regression model predicting report rate:
$$\text{ReportRate}_i = \beta_0 + \beta_1 \log(\text{Visits}_i) + \boldsymbol{\gamma} \mathbf{X}_i + \varepsilon_i$$
Where $\mathbf{X}_i$ includes vector embeddings of ad copy, automated content flags, category controls, and landing page safety scores.
- If $\beta_1$ drops to zero after adding creative features ($\mathbf{X}_i$), then bad content drives both high clicks (clickbait) and high reports.
Step 5: Validity and Moderation Review (Testing H3)
Analyze the confirmation_precision_pct metric from Step 1 across volume deciles.
- A falling confirmation rate in high-volume deciles points to user over-reporting, accidental clicks on mobile placements, or coordinated flagging.
- A stable or rising confirmation rate confirms genuine policy violations escaping automated pre-ad screening due to high delivery speed.