Integration Specifications
This article will help you learn about how Daasity replicates data from GA4 BigQuery, limitations to the data we can extract and where the data is stored in the GA4 BigQuery schema.
Integration Overview
Google Analytics V4 is the newest version of Google Analytics, wherein raw event data from Google Analytics V4 properties can be exported to BigQuery and then fetched through a series of SQL queries.
This document provides context on what kind of data is being gathered through this extractor, which endpoints that data is coming from, and how the extracted tables relate to each other.
Integration Availability
This integration is available for:
Enterprise
Growth
BigQuery Export
The Daasity GA4 BigQuery extractor is built based on this GA4 BigQuery Export Documentation. Staging tables are extracted from BigQuery Exports via SQL and are then stitched together during the transformation process to create the standard GA report tables. The Daasity GA4 BigQuery extractor fetches reports in the following time periods:
Full day (tables ending in _stg1)
Intraday (tables ending in _stg2)
Hourly
Entity Relationship Diagram (ERD)
Click here to view the Daasity GA4 BigQuery integration illustrating the different tables and keys to join across tables.
GA4 BigQuery Schema
The Daasity GA4 BigQuery extractor creates these tables using SQL and replication methods listed. The data is mapped from BigQuery to the table based on the mapping logic outlined in each table.
Base Landing Page
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_landing_page_stg1][
ga4_bq_stg.base_landing_page_stg2]
MD5('<%= integration.account.id %>'||':'||stream_id||':'||created_on||':'||IFNULL(REGEXP_REPLACE(landing_page, r'[\n\r\?].*', ''),''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
REGEXP_REPLACE(landing_page, r'[\n\r\?].*', '')
landing_page_path
SUM(pageviews)
pageviews
COUNT(DISTINCT ga_session_id)
sessions
COUNT(DISTINCT CASE WHEN is_engaged = 1 THEN ga_session_id END)
engaged_sessions
SUM(transactions)
transactions
SUM(session_duration)
session_duration
SUM(transaction_revenue)
transaction_revenue
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5('<%= integration.account.id %>'||':'||stream_id||':'||created_on||':'||IFNULL(REGEXP_REPLACE(landing_page, r'[\n\r\?].*', ''),''))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base PDP Performance
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_pdp_performance_stg1][
ga4_bq_stg.base_pdp_performance_stg2]
MD5('<%= integration.account.id %>'||':'||stream_id||':'||event_date||':'||item_name||':'||REPLACE(item_id,'\n','')||':'||IFNULL(currency,''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
item_name
product_name
REPLACE(item_id,'\n','')
product_sku
currency
currency
COUNT(CASE WHEN event_name = 'view_item' THEN CONCAT(user_pseudo_id,event_timestamp) END)
product_detail_views
COUNT(CASE WHEN event_name = 'add_to_cart' THEN CONCAT(user_pseudo_id,event_timestamp) END)
product_adds_to_cart
COUNT(CASE WHEN event_name = 'begin_checkout' THEN CONCAT(user_pseudo_id,event_timestamp) END)
product_checkouts
SUM(CASE WHEN event_name = 'purchase' THEN item_revenue ELSE 0 END)
product_sales
COUNT(DISTINCT CASE WHEN event_name = 'purchase' THEN transaction_id END)
product_purchases
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5('<%= integration.account.id %>'||':'||stream_id||':'||event_date||':'||item_name||':'||REPLACE(item_id,'\n','')||':'||IFNULL(currency,''))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base Shopping Stage
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_shopping_stage_stg1][
ga4_bq_stg.base_shopping_stage_stg2]
MD5('<%= integration.account.id %>'||':'||IFNULL(stream_id,'')||':'||IFNULL(created_on,'2000-01-01')||':'||IFNULL(source,'')||':'||IFNULL(medium,'')||':'||IFNULL(campaign,'')||':'||IFNULL(channel_grouping,'')||':'||IFNULL(term,'')||':'||IFNULL(content,'')||':'||IFNULL(shopping_stage,'')||':'||CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||IFNULL(device_category,''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
source
source
medium
medium
campaign
campaign
shopping_stage
shopping_stage
LOWER(session_traffic_source_last_click.cross_channel_campaign.default_channel_group) (first non-null value in the session)
channel_grouping
CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END
user_type
device_category
device_category
COUNT(DISTINCT ga_session_id)
sessions
term
keyword
content
adcontent
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5('<%= integration.account.id %>'||':'||IFNULL(stream_id,'')||':'||IFNULL(created_on,'2000-01-01')||':'||IFNULL(source,'')||':'||IFNULL(medium,'')||':'||IFNULL(campaign,'')||':'||IFNULL(channel_grouping,'')||':'||IFNULL(term,'')||':'||IFNULL(content,'')||':'||IFNULL(shopping_stage,'')||':'||CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||IFNULL(device_category,''))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base Transactions
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_transactions_stg1][
ga4_bq_stg.base_transactions_stg2]
MD5('<%= integration.account.id %>'||':'||stream_id||':'||transaction_id)
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
transaction_id
transaction_id
source
source
medium
medium
campaign
campaign
LOWER(session_traffic_source_last_click.cross_channel_campaign.default_channel_group) (first non-null value in the session)
channel_grouping
CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END
user_type
NULL
country_iso_code
device_category
device_category
NULLIF(country,'')
country
city
city
REGEXP_REPLACE(full_referrer, r'[\n\r\?].*', '')
full_referrer
region
region
browser
browser
operating_system
operating_system
term
keyword
content
adcontent
FIRST_VALUE(purchase_revenue_in_usd IGNORE NULLS) OVER (PARTITION BY transaction_id ORDER BY event_timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
transaction_revenue
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5('<%= integration.account.id %>'||':'||stream_id||':'||transaction_id)
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base Traffic
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_traffic_stg1][
ga4_bq_stg.base_traffic_stg2]
MD5('<%= integration.account.id %>'||':'||stream_id||':'||created_on||':'||IFNULL(source,'')||':'||IFNULL(medium,'')||':'||IFNULL(campaign,'')||':'||IFNULL(channel_grouping,'')||':'||IFNULL(term,'')||':'||IFNULL(content,'')||':'||CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(device_category,'')||':'||IFNULL(country_name,''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
source
source
medium
medium
campaign
campaign
LOWER(session_traffic_source_last_click.cross_channel_campaign.default_channel_group) (first non-null value in the session)
channel_grouping
CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END
user_type
device_category
device_category
NULL
country_iso_code
NULLIF(country_name,'')
country_name
SUM(pageviews)
pageviews
COUNT(DISTINCT ga_session_id)
sessions
COUNT(DISTINCT CASE WHEN is_engaged = 1 THEN ga_session_id END)
engaged_sessions
SUM(transactions)
transactions
SUM(session_duration)
session_duration
NULL
time_on_page
SUM(transaction_revenue)
transaction_revenue
term
keyword
content
adcontent
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5('<%= integration.account.id %>'||':'||stream_id||':'||created_on||':'||IFNULL(source,'')||':'||IFNULL(medium,'')||':'||IFNULL(campaign,'')||':'||IFNULL(channel_grouping,'')||':'||IFNULL(term,'')||':'||IFNULL(content,'')||':'||CASE WHEN ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(device_category,'')||':'||IFNULL(country_name,''))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base Traffic Hourly
Endpoint: BigQuery Export
Update Method: UPSERT
Table Names:
[
ga4_bq_stg.base_traffic_hourly_history_stg1][
ga4_bq_stg.base_traffic_hourly_history_stg2]
MD5(sm.stream_id||':'||sm.created_on||':'||DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(st.event_timestamp)),hour)||':'||IFNULL(ts.source,'')||':'||IFNULL(ts.medium,'')||':'||IFNULL(ts.campaign,'')||':'||IFNULL(ts.term,'')||':'||IFNULL(ts.content,'')||':'||IFNULL(REGEXP_REPLACE(ts.full_referrer, r'[\n\r\?].*', ''),'')||':'||CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(sm.device_category,'')||':'||IFNULL(sm.country_name,''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(event_timestamp)),hour)
date_hour_utc
source
source
medium
medium
campaign
campaign
NULL
channel_grouping
term
keyword
content
adcontent
REGEXP_REPLACE(full_referrer, r'[\n\r\?].*', '')
full_referrer
CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END
user_type
device_category
device_category
NULL
country_iso_code
NULLIF(sm.country_name,'')
country_name
SUM(pageviews)
pageviews
COUNT(DISTINCT ga_session_id)
sessions
COUNT(DISTINCT CASE WHEN is_engaged = 1 THEN ga_session_id END)
engaged_sessions
SUM(transactions)
transactions
SUM(transaction_revenue)
transaction_revenue
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
'events' ('events_intraday' in the \_stg2 table)
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5(sm.stream_id||':'||sm.created_on||':'||DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(st.event_timestamp)),hour)||':'||IFNULL(ts.source,'')||':'||IFNULL(ts.medium,'')||':'||IFNULL(ts.campaign,'')||':'||IFNULL(ts.term,'')||':'||IFNULL(ts.content,'')||':'||IFNULL(REGEXP_REPLACE(ts.full_referrer, r'[\n\r\?].*', ''),'')||':'||CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(sm.device_category,'')||':'||IFNULL(sm.country_name,''))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Base Traffic Hourly Today
Endpoint: BigQuery Export (
events_intraday_*)Update Method: UPSERT
Table Name: [
ga4_bq.base_traffic_hourly_today]
Loaded by the hourly extraction when Hourly is enabled on the integration: today's traffic by hour from the intraday export. Same SQL as Base Traffic Hourly, except for the key, the source table and the extra __integration_id column.
MD5(IFNULL(sm.stream_id,'')||':'||IFNULL(sm.created_on,'2000-01-01')||':'||IFNULL(DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(st.event_timestamp)),hour),'2000-01-01')||':'||IFNULL(ts.source,'')||':'||IFNULL(ts.medium,'')||':'||IFNULL(ts.campaign,'')||':'||IFNULL(ts.term,'')||':'||IFNULL(ts.content,'')||':'||IFNULL(REGEXP_REPLACE(ts.full_referrer, r'[\n\r\?].*', ''),'')||':'||CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(sm.device_category,'')||':'||IFNULL(sm.country_name,''))
id
stream_id
stream_id
PARSE_TIMESTAMP('%Y%m%d', event_date)
created_on
DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(event_timestamp)),hour)
date_hour_utc
source
source
medium
medium
campaign
campaign
NULL
channel_grouping
term
keyword
content
adcontent
REGEXP_REPLACE(full_referrer, r'[\n\r\?].*', '')
full_referrer
CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END
user_type
device_category
device_category
NULL
country_iso_code
NULLIF(sm.country_name,'')
country_name
SUM(pageviews)
pageviews
COUNT(DISTINCT ga_session_id)
sessions
COUNT(DISTINCT CASE WHEN is_engaged = 1 THEN ga_session_id END)
engaged_sessions
SUM(transactions)
transactions
SUM(transaction_revenue)
transaction_revenue
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
'events_intraday'
__source_table
PARSE_TIMESTAMP('%Y%m%d', _TABLE_SUFFIX)
__file_date
MD5(IFNULL(sm.stream_id,'')||':'||IFNULL(sm.created_on,'2000-01-01')||':'||IFNULL(DATETIME_TRUNC(DATETIME(TIMESTAMP_MICROS(st.event_timestamp)),hour),'2000-01-01')||':'||IFNULL(ts.source,'')||':'||IFNULL(ts.medium,'')||':'||IFNULL(ts.campaign,'')||':'||IFNULL(ts.term,'')||':'||IFNULL(ts.content,'')||':'||IFNULL(REGEXP_REPLACE(ts.full_referrer, r'[\n\r\?].*', ''),'')||':'||CASE WHEN ftu.ga_session_id IS NOT NULL THEN 'First-time' ELSE 'Returning' END||':'||IFNULL(sm.device_category,'')||':'||IFNULL(sm.country_name,''))
__sync_key
'<%= integration.account.id %>'
_account_id
'<%= integration.id %>'
__integration_id
CURRENT_TIMESTAMP()
__synced_at
Base Multi-Channel Funnel
Endpoint: BigQuery Export (
events_*andevents_intraday_*)Update Method: UPSERT
Table Name: [
ga4_bq_stg.base_multi_channel_funnel]
Loaded by the daily extraction when Multi-Channel Funnel is enabled on the integration (the default). One row per page_view with a traffic source that the same user had in the 30 days up to a purchase, for each purchase; consecutive page views with the same session and source are collapsed into one.
TO_HEX(MD5( ga4_property_id ||':'||stream_id ||':'||IFNULL(user_pseudo_id,'') ||':'||IFNULL(user_id,'') ||':'||transaction_id ||':'||CAST(transaction_timestamp AS STRING) ||':'||session_id ||':'||CAST(event_timestamp AS STRING) ||':'||IFNULL(source,'') ||':'||IFNULL(medium,'') ||':'||IFNULL(campaign,'') ||':'||IFNULL(content,'') ||':'||IFNULL(term,'') ||':'||IFNULL(REGEXP_REPLACE(page_location, r'[\n\r\?].*', ''),'') ||':'||'<%= integration.account.id %>' ))
id
REGEXP_EXTRACT(dataset name, r'\d+')
ga4_property_id
stream_id
stream_id
user_pseudo_id
user_pseudo_id
user_id
user_id
ecommerce.transaction_id of the purchase event
transaction_id
event_timestamp of the purchase event
transaction_timestamp
user_pseudo_id || (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id')
session_id
event_timestamp of the page_view event
event_timestamp
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'source')
source
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'medium')
medium
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'campaign')
campaign
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'content')
content
(SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'term')
term
REGEXP_REPLACE((SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location'), r'[\n\r\?].*', '')
page_location
NULL
channel_grouping
NULL
channel
NULL
vendor
NULL
sub_channel
NULL
media_type
NULL
attribution_channel
TO_HEX(MD5( ga4_property_id ||':'||stream_id ||':'||IFNULL(user_pseudo_id,'') ||':'||IFNULL(user_id,'') ||':'||transaction_id ||':'||CAST(transaction_timestamp AS STRING) ||':'||session_id ||':'||CAST(event_timestamp AS STRING) ||':'||IFNULL(source,'') ||':'||IFNULL(medium,'') ||':'||IFNULL(campaign,'') ||':'||IFNULL(content,'') ||':'||IFNULL(term,'') ||':'||IFNULL(REGEXP_REPLACE(page_location, r'[\n\r\?].*', ''),'') ||':'||'<%= integration.account.id %>' ))
__sync_key
'<%= integration.account.id %>'
_account_id
CURRENT_TIMESTAMP()
__synced_at
Was this helpful?