BigQuery Abfrage für Google Analytics (UA): Event-Tracking: Dimensionen und Metriken

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.

Event-Tracking Dimensionen

  • event category
  • event action
  • event label

Event-Tracking Metriken

  • total events
  • unique events
  • event value
  • avg. value
  • sessions with event
  • events / session with event
select
  -- event category (dimension)
  hits.eventinfo.eventcategory as event_category,
  -- event action (dimension)
  hits.eventinfo.eventaction as event_action,
  -- event label (dimension)
  hits.eventinfo.eventlabel as event_label,
  -- total events (metric)
  count(*) as total_events,
  -- unique events (metric),
  count(distinct concat(cast(fullvisitorid as string), cast(visitstarttime as string))) as unique_events,
  -- event value (metric)
  sum(hits.eventinfo.eventvalue) as event_value,
  -- avg. value (metric)
  sum(hits.eventinfo.eventvalue) / count(*) as avg_value,
  -- sessions with events (metric)
  count(distinct case when hits.type = 'EVENT' then concat(cast(fullvisitorid as string), cast(visitstarttime as string)) else null end) as sessions_with_events,
  -- events / session with event (metric)
  ifnull(safe_divide(count(*),count(distinct case when hits.type = 'event' then concat(cast(fullvisitorid as string), cast(visitstarttime as string)) else null end)),0) as events_session_with_event
from
  `bigquery-public-data.google_analytics_sample.ga_sessions_20160801`,
  unnest(hits) as hits
where
  totals.visits = 1
  and hits.type = 'EVENT'
group by
  event_category,
  event_action,
  event_label
having
  event_category is not null
order by
  total_events desc