|
| 1 | +-- noqa: disable=PRS |
| 2 | +-- Detection logic explained: |
| 3 | +-- https://github.com/privacycg/proposals/issues/6 |
| 4 | +-- https://github.com/privacycg/nav-tracking-mitigations/blob/main/bounce-tracking-explainer.md |
| 5 | + |
| 6 | +WITH redirect_requests AS ( |
| 7 | + FROM `httparchive.crawl.requests` |
| 8 | + |> WHERE |
| 9 | + date = '2025-07-01' AND |
| 10 | + --rank = 1000 AND |
| 11 | + SAFE.INT64(summary.status) BETWEEN 300 AND 399 AND |
| 12 | + index <= 2 |
| 13 | + |> JOIN UNNEST(response_headers) AS header |
| 14 | + |> WHERE LOWER(header.name) = 'location' |
| 15 | + |> SELECT |
| 16 | + client, |
| 17 | + url, |
| 18 | + index, |
| 19 | + NET.REG_DOMAIN(header.value) AS location_domain, |
| 20 | + root_page |
| 21 | +), |
| 22 | + |
| 23 | +-- Find the first navigation redirect |
| 24 | +navigation_redirect AS ( |
| 25 | + FROM redirect_requests |
| 26 | + |> WHERE |
| 27 | + index = 1 AND |
| 28 | + NET.REG_DOMAIN(root_page) = NET.REG_DOMAIN(url) AND |
| 29 | + NET.REG_DOMAIN(url) != location_domain |
| 30 | + |> SELECT |
| 31 | + client, |
| 32 | + root_page, |
| 33 | + location_domain AS bounce_domain |
| 34 | +), |
| 35 | + |
| 36 | +-- Find the second navigation redirect |
| 37 | +bounce_redirect AS ( |
| 38 | + FROM redirect_requests |
| 39 | + |> WHERE |
| 40 | + index = 2 AND |
| 41 | + NET.REG_DOMAIN(root_page) != NET.REG_DOMAIN(url) AND |
| 42 | + NET.REG_DOMAIN(url) != location_domain |
| 43 | + |> SELECT |
| 44 | + client, |
| 45 | + url, |
| 46 | + root_page, |
| 47 | + location_domain AS bounce_redirect_location_domain |
| 48 | +), |
| 49 | + |
| 50 | +-- Combine the first and second navigation redirects |
| 51 | +bounce_sequences AS ( |
| 52 | + FROM navigation_redirect AS nav |
| 53 | + |> JOIN bounce_redirect AS bounce |
| 54 | + ON |
| 55 | + nav.client = bounce.client AND |
| 56 | + nav.root_page = bounce.root_page |
| 57 | + |> AGGREGATE COUNT(DISTINCT nav.root_page) AS websites_count |
| 58 | + GROUP BY nav.client, bounce_domain |
| 59 | +), |
| 60 | + |
| 61 | +websites_total AS ( |
| 62 | + FROM `httparchive.crawl.pages` |
| 63 | + |> WHERE date = '2025-07-01' --AND rank = 1000 |
| 64 | + |> AGGREGATE COUNT(DISTINCT root_page) AS total_websites GROUP BY client |
| 65 | +) |
| 66 | + |
| 67 | +FROM bounce_sequences |
| 68 | +|> JOIN websites_total USING (client) |
| 69 | +|> EXTEND websites_count / total_websites AS websites_pct |
| 70 | +|> DROP total_websites |
| 71 | +|> PIVOT( |
| 72 | + ANY_VALUE(websites_count) AS cnt, |
| 73 | + ANY_VALUE(websites_pct) AS pct |
| 74 | + FOR client IN ('desktop', 'mobile') |
| 75 | +) |
| 76 | +|> RENAME pct_mobile AS mobile, pct_desktop AS desktop, cnt_mobile AS mobile_count, cnt_desktop AS desktop_count |
| 77 | +|> ORDER BY COALESCE(mobile_count, 0) + COALESCE(desktop_count, 0) DESC |
| 78 | +|> LIMIT 100 |
0 commit comments