Erstellung des „Geräte-Übersicht“ Berichtes in Big Query mit Universal Analytics Daten

Im Bericht Geräteübersicht finden Sie Daten über die Akquisition, das Verhalten und die Conversions Ihrer Nutzer, aufgeschlüsselt nach Modell des mobilen Geräts, Marke des mobilen Geräts, Betriebssystem, Betriebssystemversion, Browser, Browserversion, Browsergröße und Bildschirmauflösung.

select 
  device.mobiledevicebranding,
  -- device.mobiledevicemarketingname,
  -- device.mobiledevicemodel,
  -- device.mobiledeviceinfo,
  -- device.browser,
  -- device.browserversion,
  -- device.browsersize,
  -- device.operatingsystem,
  -- device.operatingsystemversion,
  -- device.screenresolution,
  count(distinct fullvisitorid) as users,
  count(distinct(case when totals.newvisits = 1 then fullvisitorid else null end)) as new_users,
  count(distinct concat(fullvisitorid, cast(visitstarttime as string))) as sessions,
  count(distinct case when totals.bounces = 1 then concat(fullvisitorid, cast(visitstarttime as string)) else null end ) / count(distinct concat(fullvisitorid, cast(visitstarttime as string))) as bounce_rate,
  sum(totals.pageviews) / count(distinct concat(fullvisitorid, cast(visitstarttime as string))) as pages_per_session,
  ifnull(sum(totals.timeonsite) / count(distinct concat(fullvisitorid, cast(visitstarttime as string))),0) as average_session_duration,
  ifnull(sum(totals.transactions),0) as transactions,
  ifnull(sum(totals.totaltransactionrevenue),0)/1000000 as revenue,
  ifnull(sum(totals.transactions) / count(distinct concat(fullvisitorid, cast(visitstarttime as string))),0) as ecommerce_conversion_rate
from
  `bigquery-public-data.google_analytics_sample.ga_sessions_20160801`
where
  totals.visits = 1
group by
  device.mobiledevicebranding
  -- ,device.mobiledevicemarketingname
  -- ,device.mobiledevicemodel
  -- ,device.mobiledeviceinfo
  -- ,browser
  -- ,browserversion
  -- ,browsersize
  -- ,operatingsystem
  -- ,operatingsystemversion
  -- ,screenresolution
order by
  users desc