Daniel
Daniel

Reputation: 5381

Get total custom dimensions

I'm trying to get the total costume dimensions used in the session but I'm getting the following error. How can I fix this

select count(hits.product.customDimensions.value)
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_xxxx`,
UNNEST(hits) AS hits,
UNNEST(hits.product) AS prod,
UNNEST(hits.product.customDimensions) AS cust

I'm getting the following error

Cannot access field customDimensions on a value with type ARRAY<STRUCT<productSKU STRING, v2ProductName STRING, v2ProductCategory STRING, ...>> at [5:21]

Upvotes: 0

Views: 81

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172944

Try below

select count(cust.value)
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`,
UNNEST(hits) AS hits,
UNNEST(hits.product) AS prod,
UNNEST(prod.customDimensions) AS cust

Upvotes: 2

Related Questions