-
-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathiab_usp_strings_top.sql
More file actions
28 lines (26 loc) · 1.02 KB
/
iab_usp_strings_top.sql
File metadata and controls
28 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- noqa: disable=PRS
-- Counts of US Privacy String values for websites using IAB US Privacy Framework
-- cf. https://github.com/InteractiveAdvertisingBureau/USPrivacy/blob/master/CCPA/US%20Privacy%20String.md
WITH base_totals AS (
SELECT
client,
COUNT(DISTINCT root_page) AS total_websites
FROM `httparchive.crawl.pages`
WHERE date = '2025-07-01'
GROUP BY client
)
FROM `httparchive.crawl.pages`
|> WHERE date = '2025-07-01'
|> EXTEND UPPER(SAFE.STRING(custom_metrics.privacy.iab_usp.privacy_string.uspString)) AS uspString
|> WHERE uspString IS NOT NULL
|> AGGREGATE COUNT(DISTINCT root_page) AS websites_count GROUP BY client, uspString
|> JOIN base_totals USING (client)
|> EXTEND websites_count / total_websites AS pct_websites
|> DROP total_websites
|> PIVOT(
ANY_VALUE(websites_count) AS websites_count,
ANY_VALUE(pct_websites) AS pct
FOR client IN ('desktop', 'mobile')
)
|> RENAME pct_mobile AS Mobile, pct_desktop AS Desktop
|> ORDER BY COALESCE(websites_count_desktop, 0) + COALESCE(websites_count_mobile, 0) DESC