简体   繁体   English

CWV 数据的问题 - GA4 + BigQuery + Data Studio

[英]Problems with CWV data - GA4 + BigQuery + Data Studio

Following this guide https://web.dev/vitals-ga4 , in Google Cloud Platform I'm seeing this: https://i.stack.imgur.com/NSy5h.jpg按照本指南https://web.dev/vitals-ga4 ,在 Google Cloud Platform 中我看到了这个: https://i.stack.imgur.com/NSy5h.jpg

Using this query https://web.dev/vitals-ga4/#analyze I'm getting this https://i.stack.imgur.com/AV1iy.png使用这个查询https://web.dev/vitals-ga4/#analyze我得到这个https://i.stack.imgur.com/AV1iy.png

As the blog post mention "For Web Vitals events, the last value sent is always the most accurate one, so before performing any analysis, it's important to filter for just those values. The code snippet provided by the web-vitals JavaScript library to send data to Google Analytics 4 includes sending a unique ID per metric, so you can use the following query to limit your results to just the last-received value for each metric ID:"正如博文中提到的“对于 Web Vitals 事件,发送的最后一个值始终是最准确的值,因此在执行任何分析之前,重要的是只过滤这些值。web-vitals JavaScript 库提供的代码片段发送向 Google Analytics 4 发送数据包括为每个指标发送一个唯一 ID,因此您可以使用以下查询将结果限制为每个指标 ID 的最后接收值:”

I used this query https://web.dev/vitals-ga4/#query-web-vitals-data and I'm getting a syntax error https://i.stack.imgur.com/72ScT.png我使用了这个查询https://web.dev/vitals-ga4/#query-web-vitals-data我得到了一个语法错误https://i.stack.imgur.com/72ScT.png

(sry for no links, but I don't have enough reputation to use them - and I will post any screen shoot that will help in comm) (抱歉没有链接,但我没有足够的声誉来使用它们 - 我会发布任何有助于交流的屏幕截图)

That WITH statement appears to only be the first half of the query.WITH语句似乎只是查询的前半部分。 The error message is saying that you need a corresponding SELECT statement to make use of the web_vitals_events common table expression (CTE).错误消息是说您需要相应的SELECT语句才能使用web_vitals_events公用表表达式 (CTE)。

See the Example queries section further down for full, working query samples.请参阅下面的示例查询部分,了解完整的、有效的查询示例。 Here's an example query to get the 75th percentiles for each CWV metric:以下是获取每个 CWV 指标的第 75 个百分位数的示例查询:

# Subquery all Web Vitals events from the last 28 days
WITH web_vitals_events AS (
  SELECT event_name as metric_name, * EXCEPT(event_name, is_last_received_value) FROM (
    SELECT *, IF (ROW_NUMBER() OVER (
      PARTITION BY (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'metric_id')
      ORDER BY (SELECT COALESCE(value.double_value, value.int_value) FROM UNNEST(event_params) WHERE key = 'metric_value') DESC
    ) = 1, true, false) AS is_last_received_value
    FROM `bigquery_project_id.analytics_XXXXX.events_*`
    WHERE event_name in ('CLS', 'FID', 'LCP') AND
      _TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE, INTERVAL 28 DAY)) AND FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY))
  ) WHERE is_last_received_value
)

# Main query logic
SELECT
  metric_name,
  APPROX_QUANTILES(metric_value, 100)[OFFSET(75)] AS p75,
  COUNT(1) as count
FROM (
  SELECT
    metric_name,
    ROUND((SELECT COALESCE(value.double_value, value.int_value) FROM UNNEST(event_params) WHERE key = "metric_value"), 3) AS metric_value,
  FROM web_vitals_events
)
GROUP BY 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM