Skip to content

Instantly share code, notes, and snippets.

@konosp
Created November 8, 2019 09:54
Show Gist options
  • Select an option

  • Save konosp/0af9f6d7ae276f143e135998b9966011 to your computer and use it in GitHub Desktop.

Select an option

Save konosp/0af9f6d7ae276f143e135998b9966011 to your computer and use it in GitHub Desktop.
-- This query will return no intraday data as there is no intraday data available in the sample data set.
SELECT
_table_suffix AS Table_Suffix,
COUNT(DISTINCT CONCAT(fullVisitorId, CAST(visitStartTime AS STRING))) AS Sessions
FROM
`bigquery-public-data.google_analytics_sample.ga_sessions_*`
WHERE
REGEXP_EXTRACT(_table_suffix, r'[0-9]+') BETWEEN '20160801'
AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())
AND totals.visits = 1
GROUP BY
1
ORDER BY
1 DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment