Skip to content

Commit 01473ee

Browse files
committed
Add one more query
1 parent 9373c0a commit 01473ee

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#standardSQL
2+
# CrUX Core Web Vitals performance of Ecommerce vendors by device (fid was upated to inp, and is non optinal now)
3+
CREATE TEMP FUNCTION IS_GOOD(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
4+
good / (good + needs_improvement + poor) >= 0.75
5+
);
6+
7+
CREATE TEMP FUNCTION IS_NON_ZERO(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS (
8+
good + needs_improvement + poor > 0
9+
);
10+
11+
12+
SELECT
13+
date,
14+
client,
15+
ecomm,
16+
COUNT(DISTINCT origin) AS origins,
17+
# Origins with good LCP divided by origins with any LCP.
18+
SAFE_DIVIDE(
19+
COUNT(DISTINCT IF(IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)),
20+
COUNT(DISTINCT IF(IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL))
21+
) AS pct_good_lcp,
22+
23+
# Origins with good INP divided by origins with any inp.
24+
SAFE_DIVIDE(
25+
COUNT(DISTINCT IF(IS_GOOD(fast_inp, avg_inp, slow_inp), origin, NULL)),
26+
COUNT(DISTINCT IF(IS_NON_ZERO(fast_inp, avg_inp, slow_inp), origin, NULL))
27+
) AS pct_good_inp,
28+
29+
# Origins with good CLS divided by origins with any CLS.
30+
SAFE_DIVIDE(
31+
COUNT(DISTINCT IF(IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)),
32+
COUNT(DISTINCT IF(IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL))
33+
) AS pct_good_cls,
34+
35+
# Origins with good LCP, inp, and CLS divided by origins with any LCP, inp, and CLS.
36+
SAFE_DIVIDE(
37+
COUNT(DISTINCT IF(
38+
IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND
39+
IS_GOOD(fast_inp, avg_inp, slow_inp) AND
40+
IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL
41+
)),
42+
COUNT(DISTINCT IF(
43+
IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND
44+
IS_NON_ZERO(fast_inp, avg_inp, slow_inp) AND
45+
IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL
46+
))
47+
) AS pct_good_cwv
48+
FROM
49+
`chrome-ux-report.materialized.device_summary`
50+
JOIN (
51+
SELECT DISTINCT
52+
date,
53+
client,
54+
root_page,
55+
tech.technology AS ecomm
56+
FROM
57+
`httparchive.crawl.pages`,
58+
UNNEST(technologies) AS tech,
59+
UNNEST(tech.categories) AS category
60+
WHERE
61+
date = '2025-07-01' AND
62+
category = 'Ecommerce' AND
63+
(
64+
tech.technology != 'Cart Functionality' AND
65+
tech.technology != 'Google Analytics Enhanced eCommerce'
66+
)
67+
)
68+
ON
69+
CONCAT(origin, '/') = root_page AND
70+
IF(device = 'desktop', 'desktop', 'mobile') = client AND
71+
date
72+
WHERE
73+
date = '2025-07-01'
74+
GROUP BY
75+
client,
76+
ecomm
77+
ORDER BY
78+
origins DESC

0 commit comments

Comments
 (0)