Google Analytics 4 DAGs

Overview

The page will guide you how to configure tcrm_bq_to_ga4 or tcrm_gcs_to_ga4 DAG and how to prepare the data.

Google Analytics 4 (formerly known as “App + Web) is a new kind of property, with different reports than what you're used to seeing in Universal Analytics properties. One advantage of a Google Analytics 4 property is that you can use it for a website, an app, or both a website and app together. Universal Analytics properties only support websites. Read the announcement to learn more.

For detail, please refer to Meet the next generation of Google Analytics

Configure Airflow Variables

Create New Necessary tcrm_bq_to_ga4 DAG Variables

The following table indicates which variables are needed to run the tcrm_bq_to_ga4 DAG. You only need to set up these variables if you plan to use BigQuery as your data source.

Variable Name Default Value Variable Information
bq_dataset_id my_dataset The name of the BigQuery dataset containing the data.
bq_table_id my_table The name of the BigQuery table containing the data.
api_secret Google Analytics 4 API secret, please refer to query parameter section for detail about how to create the API secret
payload_type Choose from gtag or firebase
measurement_id Required if payload_type is gtag
firebase_app_id Required if payload_type is firebase

Create New Necessary tcrm_gcs_to_ga4 DAG Variables

The following table indicates which variables are needed to run the tcrm_gcs_to_ga4 DAG. You only need to set up these variables if you plan to use Google Cloud Storage as your data source.

Variable Name Example Value Variable Information
gcs_bucket_name my_bucket Cloud Storage bucket name.
gcs_bucket_prefix folder/sub_folder The path to the data folder inside the bucket.
gcs_content_type JSON Cloud Storage content type.
api_secret Google Analytics 4 API secret, please refer to query parameter section for detail about how to create the API secret
payload_type gtag Choose from gtag or firebase
measurement_id Required if payload_type is gtag
firebase_app_id Required if payload_type is firebase

Prepare Data to Send to Google Analytics 4

NOTE: Refer to the Measurement Protocol 4 API{target="_blank"} for the detailed requirements.

To send your data to GA4 you can choose from the following 2 options, example data is based on login event.:

  1. From BigQuery using the tcrm_bq_to_ga4 DAG in SQL table Format.

    id payload
    1 {"client_id":1,"events":[{"name":"login" "params":{"method": "Google"}}]} }
  2. From Google Cloud Storage using the tcrm_gcs_to_ga4 DAG in JSON Format.

    {"id": 1, "payload":{"client_id":1,"events":[{"name":"login", "params":{"method": "Google"}}]} }
    

Run Your DAG

In the Airflow console click on the DAGs option from the top menu bar. Find the DAG you’d like to run in the list on the left. Then run it by clicking the Play button on the right side of the list.

Reading DAG's Logs

Please refer to Reading DAG's Logs in FAQ.