Diese Beispielabfrage enthält alle folgenden Google Analytics-Nutzerdimensionen und Metriken. Wenn Sie nur eine Dimension oder Metrik benötigen, sehen Sie sich die — Kommentare in der Beispielabfrage an und kopieren Sie den Teil, den Sie benötigen, aus der Select-Klausel. Stellen Sie sicher, dass Sie auch alle zusätzlichen Bedingungen (in der from-, where-, group by- und order by-Klausel) hinzufügen, die zur korrekten Berechnung der Ergebnisse erforderlich sind.
Individuelle Dimensionen
- custom dimension xx (user)
- custom dimension xx (session)
- custom dimension xx (hit)
- custom dimension xx (product)
Individuelle Metriken
- custom metric xx value (hit)
- custom metric xx value (product)
-- most sample set custom dimensions return null values
select
-- custom dimension xx (user)
(select value from unnest(session.customdimensions) where index = 3 group by value) as custom_dimension_xx_user,
-- custom dimension xx (session)
(select value from unnest(session.customdimensions) where index = 4 group by value) as custom_dimension_xx_session,
-- custom dimension xx (hit)
(select value from unnest(hits.customdimensions) where index = 2 group by value) as custom_dimension_xx_hit,
-- custom dimension xx (product)
(select value from unnest(product.customdimensions) where index = 10 group by value) as custom_dimension_xx_product,
-- custom metric xx (hit)
sum((select value from unnest(hits.custommetrics) where index = 1)) as custom_metric_xx_hit,
-- custom metric xx (product)
sum((select value from unnest(product.custommetrics) where index = 2)) as custom_metric_xx_product
from
`bigquery-public-data.google_analytics_sample.ga_sessions_20160801` as session,
unnest(hits) as hits,
unnest(product) as product
where
totals.visits = 1
group by
custom_dimension_xx_user,
custom_dimension_xx_session,
custom_dimension_xx_hit,
custom_dimension_xx_product
order by
custom_metric_xx_hit desc