====== Connect GA4 to BigQuery ====== If you want to run enhanced custom analysis on the data you logged on GA4, you can easily connect your GA4 property to a [[https://cloud.google.com/bigquery|Google BigQuery]] project to have access to all the logged data and run custom complex queries on them. Google offers a free BigQuery //sandbox// that you can use for free to start working on your data. Read [[https://cloud.google.com/bigquery/docs/sandbox|Enable the BigQuery sandbox]] to enable it. ===== Quick configuration ===== * Ensure to have a working BigQuery environment (if needed, you can [[https://cloud.google.com/bigquery/docs/sandbox|setup a free BigQuery sandbox]]) * Open your GA4 property at [[https://analytics.google.com/analytics/web/]] * Navigate to //Admin > BigQuery links > Link// * Complete the steps to create the connection from GA4 to BigQuery * Wait for data to flow (see note below) * Open your [[https://console.cloud.google.com/bigquery|BigQuery console]] and select your new data source Note from Google documentation: > Analytics will update daily tables for up to 72 hours beyond the date of the table with events that are timestamped with the date of the table So, after the initial setup, usually you have to wait before seeing some data available in BigQuery. Helpful links to official documentation: * [[https://support.google.com/analytics/topic/9359001|[GA4] BigQuery Export integration]] * [[https://support.google.com/analytics/answer/9823238|[GA4] Set up BigQuery Export]] * [[https://cloud.google.com/bigquery/docs/sandbox|Enable the BigQuery sandbox]] ===== Sample queries ===== Once your data are available in your BigQuery project, you can easily run some simple queries on them. Dump the latest events, ordered by timestamp: SELECT STRING(TIMESTAMP_MICROS(event_timestamp)) as TS, * FROM `..` ORDER BY event_timestamp LIMIT 1000; {{ :ue5-google-analytics:ga4-bigquery-sample.png |}} Dump the latest events, ordered by timestamp and batch index: SELECT STRING(TIMESTAMP_MICROS(event_timestamp)) as TS, * FROM `ue4-ga4-test.analytics_270803549.events_20240411` ORDER BY event_timestamp, (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'batch_ordering_id') LIMIT 1000 In case of issues, check the logs at [[https://console.cloud.google.com/logs]].