-
-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathiab_tcf_v2_countries_top.sql
More file actions
41 lines (38 loc) · 1.38 KB
/
iab_tcf_v2_countries_top.sql
File metadata and controls
41 lines (38 loc) · 1.38 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
29
30
31
32
33
34
35
36
37
38
39
40
41
-- noqa: disable=PRS
-- Counts of countries for publishers using IAB Transparency & Consent Framework
-- cf. https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md--tcdata
-- "Country code of the country that determines the legislation of
-- reference. Normally corresponds to the country code of the country
-- in which the publisher's business entity is established."
WITH base_totals AS (
SELECT
client,
COUNT(DISTINCT root_page) AS total_websites
FROM `httparchive.crawl.pages`
WHERE date = '2025-07-01' --AND rank = 1000
GROUP BY client
),
base_data AS (
SELECT
client,
root_page,
UPPER(SAFE.STRING(custom_metrics.privacy.iab_tcf_v2.data.publisherCC)) AS publisherCC
FROM `httparchive.crawl.pages`
WHERE
date = '2025-07-01' AND --rank = 1000 AND
JSON_TYPE(custom_metrics.privacy.iab_tcf_v2.data) = 'object'
)
FROM base_data
|> AGGREGATE
COUNT(DISTINCT root_page) AS number_of_pages
GROUP BY client, publisherCC
|> JOIN base_totals USING (client)
|> EXTEND number_of_pages / total_websites AS pct_of_pages
|> DROP total_websites
|> PIVOT(
ANY_VALUE(number_of_pages) AS pages_count,
ANY_VALUE(pct_of_pages) AS pct
FOR client IN ('desktop', 'mobile')
)
|> RENAME pct_mobile AS mobile, pct_desktop AS desktop
|> ORDER BY pages_count_mobile + pages_count_desktop DESC