google-big-queryHow can I use Google Analytics and BigQuery together to analyze website data?
Google Analytics and BigQuery can be used together to analyze website data in a few different ways.
First, you can export the Google Analytics data to BigQuery and then use SQL queries to analyze the data. For example, the following query will return the total number of pageviews for a website in the last 30 days:
SELECT
date,
SUM(totals.pageviews) AS pageviews
FROM
`ga_sessions_*`
WHERE
_TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d',DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY))
AND FORMAT_DATE('%Y%m%d',CURRENT_DATE())
GROUP BY
date
ORDER BY
date ASC
Output example
date pageviews
2020-05-01 15000
2020-05-02 16000
2020-05-03 17000
2020-05-04 18000
...
Second, you can use BigQuery to create custom metrics and dimensions in Google Analytics. For example, the following query will create a custom metric that calculates the average pageviews per session:
SELECT
date,
AVG(totals.pageviews) AS avg_pageviews_per_session
FROM
`ga_sessions_*`
GROUP BY
date
ORDER BY
date ASC
Once the custom metric is created, it can be used in Google Analytics to analyze the data.
More of Google Big Query
- How do I start using Google Big Query?
- How can I create a Google BigQuery table?
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
- How do I use Google Big Query with Excel?
- How can I use the CASE WHEN statement in Google Big Query?
- How can I use Google Big Query with Udemy?
- How can I use Google Big Query to count the number of zeros in a given dataset?
- How can I get started with Google BigQuery training?
- How do I use Google Big Query SQL for software development?
- How can I use Google Big Query with PHP?
See more codes...