我尝试使用标准SQL复制GA数量指标(ga:itemQuantity)并查询GA导出到BigQuery日期分区表(ga_sessions_YYYYMMDD)。
我尝试了以下内容,但数量为'始终为空:
#standardSQL
SELECT
sum(hit.item.itemQuantity) as quantity
FROM `precise-armor-133520.1500218.ga_sessions_20170801` t
CROSS JOIN
UNNEST(t.hits) AS hit
order by 1 ASC;
其他指标与GA用户界面100%匹配,因此我假设它不是数据导出问题。例如:
SELECT
sum( totals.totalTransactionRevenue ) as revenue, sum( totals.transactions ) as transactions
FROM `precise-armor-133520.1500218.ga_sessions_201708*` t
CROSS JOIN
UNNEST(t.hits) AS hit
group by `date`
order by `date` asc
这些总计分别与GA UI中的收入和交易(指标)相匹配。
GA指标数量的标准SQL查询是什么(ga:itemQuantity)?
答案 0 :(得分:1)
为了匹配"数量"在GA的每个日期的Web UI中,使用以下标准SQL:
SELECT
SUM(product.productQuantity)
,`date`
FROM
`precise-armor-133520.1500218.ga_sessions_*`
,UNNEST(hits) AS hits
,UNNEST(hits.product) AS product
WHERE hits.eCommerceAction.action_type = "6"
and _TABLE_SUFFIX between '20170801' and FORMAT_DATE("%Y%m%d", CURRENT_DATE)
group by 2
order by 2 asc
答案 1 :(得分:0)
这有用吗?
#standardSQL
SELECT
sku,
SUM(qtd) qtd
FROM(
SELECT
ARRAY(SELECT AS STRUCT productSKU sku, productQuantity qtd FROM UNNEST(hits), UNNEST(product) WHERE ecommerceAction.action_type = '6') data
FROM `precise-armor-133520.1500218.ga_sessions_20170801`
),
UNNEST(data)
GROUP BY sku
ORDER BY qtd DESC
LIMIT 1000
不确定您是如何设法unnest
产品字段的,也许这可以解决您的问题。