gpt4 book ai didi

google-analytics - 计算 BigQuery 中的谷歌分析独特事件

转载 作者:行者123 更新时间:2023-12-03 17:16:15 25 4
gpt4 key购买 nike

我已经设法按 ISOweek 计算总事件,但不是使用 BigQuery 计算给定 Google Analytics 事件的唯一事件。检查 GA 时,total_events 匹配点上的 GA 接口(interface),但 unique_events 关闭。你知道我怎么能解决这个问题吗?

查询:

SELECT INTEGER(STRFTIME_UTC_USEC(PARSE_UTC_USEC(date),"%V")) iso8601_week_number,
hits.eventInfo.eventCategory,
hits.eventInfo.eventAction,
COUNT(hits.eventInfo.eventCategory) AS total_events,
EXACT_COUNT_DISTINCT(fullVisitorId) AS unique_events
FROM
TABLE_DATE_RANGE([XXXXXX.ga_sessions_], TIMESTAMP('2017-05-01'), TIMESTAMP('2017-05-07'))
WHERE
hits.type = 'EVENT' AND hits.eventInfo.eventCategory = 'BIG_Transaction'
GROUP BY
iso8601_week_number, hits.eventInfo.eventCategory, hits.eventInfo.eventAction

最佳答案

根据您需要的范围 count(distinct )不同的东西,但你总是需要满足这些条件:

  • 唯一事件是指类别、 Action 和标签的组合
  • 确保 eventAction不是 NULL
  • 确保 eventLabel不是 NULL
  • eventCategory允许为 NULL

  • 我正在使用 COALESCE()避免 NULL s

    示例 session 范围

    SELECT
    SUM( (SELECT COUNT(h.eventInfo.eventCategory) FROM t.hits h) ) events,
    SUM( (SELECT COUNT(DISTINCT
    CONCAT( h.eventInfo.eventCategory,
    COALESCE(h.eventinfo.eventaction,''),
    COALESCE(h.eventinfo.eventlabel, ''))
    )
    FROM
    t.hits h ) ) uniqueEvents
    FROM
    `google.com:analytics-bigquery.LondonCycleHelmet.ga_sessions_20130910` t

    示例命中范围

    SELECT
    h.eventInfo.eventCategory,
    COUNT(1) events,
    -- we need to take sessions into account, so we add fullvisitorid and visitstarttime
    COUNT(DISTINCT CONCAT(fullvisitorid, CAST(visitstarttime AS string),
    COALESCE(h.eventinfo.eventaction,''),
    COALESCE(h.eventinfo.eventlabel, ''))) uniqueEvents
    FROM
    `google.com:analytics-bigquery.LondonCycleHelmet.ga_sessions_20130910` t,
    t.hits h
    WHERE
    h.type='EVENT'
    GROUP BY
    1
    ORDER BY
    2 DESC

    嗯!

    关于google-analytics - 计算 BigQuery 中的谷歌分析独特事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44203413/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com