|
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 | | - client, |
14 | | - ecomm, |
15 | | - COUNT(DISTINCT origin) AS origins, |
16 | | - # Origins with good LCP divided by origins with any LCP. |
17 | | - SAFE_DIVIDE( |
18 | | - COUNT(DISTINCT IF(IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), |
19 | | - COUNT(DISTINCT IF(IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL)) |
20 | | - ) AS pct_good_lcp, |
21 | | - |
22 | | - # Origins with good INP divided by origins with any inp. |
23 | | - SAFE_DIVIDE( |
24 | | - COUNT(DISTINCT IF(IS_GOOD(fast_inp, avg_inp, slow_inp), origin, NULL)), |
25 | | - COUNT(DISTINCT IF(IS_NON_ZERO(fast_inp, avg_inp, slow_inp), origin, NULL)) |
26 | | - ) AS pct_good_inp, |
27 | | - |
28 | | - # Origins with good CLS divided by origins with any CLS. |
29 | | - SAFE_DIVIDE( |
30 | | - COUNT(DISTINCT IF(IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), |
31 | | - COUNT(DISTINCT IF(IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL)) |
32 | | - ) AS pct_good_cls, |
33 | | - |
34 | | - # Origins with good LCP, inp, and CLS divided by origins with any LCP, inp, and CLS. |
35 | | - SAFE_DIVIDE( |
36 | | - COUNT(DISTINCT IF( |
37 | | - IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND |
38 | | - IS_GOOD(fast_inp, avg_inp, slow_inp) AND |
39 | | - IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL |
40 | | - )), |
41 | | - COUNT(DISTINCT IF( |
42 | | - IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND |
43 | | - IS_NON_ZERO(fast_inp, avg_inp, slow_inp) AND |
44 | | - IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL |
45 | | - )) |
46 | | - ) AS pct_good_cwv |
47 | | -FROM |
48 | | - `chrome-ux-report.materialized.device_summary` |
49 | | -JOIN ( |
50 | | - SELECT |
51 | | - _TABLE_SUFFIX AS client, |
52 | | - url, |
53 | | - app AS ecomm |
54 | | - FROM |
55 | | - `httparchive.technologies.2025_06_01_*` |
56 | | - WHERE |
57 | | - category = 'Ecommerce' AND |
58 | | - ( |
59 | | - app != 'Cart Functionality' AND |
60 | | - app != 'Google Analytics Enhanced eCommerce' |
61 | | - ) |
62 | | -) |
63 | | -ON |
64 | | - CONCAT(origin, '/') = url AND |
65 | | - IF(device = 'desktop', 'desktop', 'mobile') = client |
66 | | -WHERE |
67 | | - date = '2025-06-01' |
68 | | -GROUP BY |
69 | | - client, |
70 | | - ecomm |
71 | | -ORDER BY |
72 | | - origins DESC |
| 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 | + client, |
| 14 | + ecomm, |
| 15 | + COUNT(DISTINCT origin) AS origins, |
| 16 | + # Origins with good LCP divided by origins with any LCP. |
| 17 | + SAFE_DIVIDE( |
| 18 | + COUNT(DISTINCT IF(IS_GOOD(fast_lcp, avg_lcp, slow_lcp), origin, NULL)), |
| 19 | + COUNT(DISTINCT IF(IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp), origin, NULL)) |
| 20 | + ) AS pct_good_lcp, |
| 21 | + |
| 22 | + # Origins with good INP divided by origins with any inp. |
| 23 | + SAFE_DIVIDE( |
| 24 | + COUNT(DISTINCT IF(IS_GOOD(fast_inp, avg_inp, slow_inp), origin, NULL)), |
| 25 | + COUNT(DISTINCT IF(IS_NON_ZERO(fast_inp, avg_inp, slow_inp), origin, NULL)) |
| 26 | + ) AS pct_good_inp, |
| 27 | + |
| 28 | + # Origins with good CLS divided by origins with any CLS. |
| 29 | + SAFE_DIVIDE( |
| 30 | + COUNT(DISTINCT IF(IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL)), |
| 31 | + COUNT(DISTINCT IF(IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL)) |
| 32 | + ) AS pct_good_cls, |
| 33 | + |
| 34 | + # Origins with good LCP, inp, and CLS divided by origins with any LCP, inp, and CLS. |
| 35 | + SAFE_DIVIDE( |
| 36 | + COUNT(DISTINCT IF( |
| 37 | + IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AND |
| 38 | + IS_GOOD(fast_inp, avg_inp, slow_inp) AND |
| 39 | + IS_GOOD(small_cls, medium_cls, large_cls), origin, NULL |
| 40 | + )), |
| 41 | + COUNT(DISTINCT IF( |
| 42 | + IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AND |
| 43 | + IS_NON_ZERO(fast_inp, avg_inp, slow_inp) AND |
| 44 | + IS_NON_ZERO(small_cls, medium_cls, large_cls), origin, NULL |
| 45 | + )) |
| 46 | + ) AS pct_good_cwv |
| 47 | +FROM |
| 48 | + `chrome-ux-report.materialized.device_summary` |
| 49 | +JOIN ( |
| 50 | + SELECT |
| 51 | + _TABLE_SUFFIX AS client, |
| 52 | + url, |
| 53 | + app AS ecomm |
| 54 | + FROM |
| 55 | + `httparchive.technologies.2025_06_01_*` |
| 56 | + WHERE |
| 57 | + category = 'Ecommerce' AND |
| 58 | + ( |
| 59 | + app != 'Cart Functionality' AND |
| 60 | + app != 'Google Analytics Enhanced eCommerce' |
| 61 | + ) |
| 62 | +) |
| 63 | +ON |
| 64 | + CONCAT(origin, '/') = url AND |
| 65 | + IF(device = 'desktop', 'desktop', 'mobile') = client |
| 66 | +WHERE |
| 67 | + date = '2025-07-01' |
| 68 | +GROUP BY |
| 69 | + client, |
| 70 | + ecomm |
| 71 | +ORDER BY |
| 72 | + origins DESC |
0 commit comments