GTM & GA4 Integration

GA4 is typically integrated via Google Tag Manager (GTM). Since all Pack Hydrogen sites use GTM, integrating GA4 through GTM enhances consent management.

Tag Setup in GTM

1. Create 4 User-Defined Data Layer Variables (DLV)

NameData Layer Variable Name
DLV - experiment_idexperiment_id
DLV - experiment_nameexperiment_name
DLV - experiment_variant_idexperiment_variant_id
DLV - experiment_variationexperiment_variation

2. Create a GA4 Event Tag for view_experiment

  • Tag Type: GA4 Event
  • Measurement ID: Replace with your actual GA4 ID
  • Event Name: view_experiment
  • Event Settings Variable: GA4 Event Settings

3. Configure Event Parameters

Event ParameterValue
experiment_idDLV - experiment_id
experiment_nameDLV - experiment_name
experiment_variant_idDLV - experiment_variant_id
experiment_variationDLV - experiment_variation

4. Configure GTM Consent Settings

  • Enable additional consent checks.
  • Require consent for: ad_storage, analytics_storage, and personalization_storage.

5. Create a GTM Trigger

  • Trigger Type: Custom Event
  • Event Name: view_experiment
  • Fires On: All Custom Events

BigQuery Integration with GA4 & PackDigital

1. Create or Use an Existing GCP Project

  • Create a new project or use an existing one via the Google Cloud Console.

2. Enable BigQuery API

  • Enable the BigQuery API for your project.

3. Create a Service Account

  • Navigate to Service Accounts → Create Service Account.
  • Assign the roles BigQuery Job User and BigQuery Data Viewer.
  • Complete the creation process.

4. Generate a Service Account Key

  • Open the created Service Account.
  • Go to Manage KeysAdd KeyCreate new key (choose JSON format).
  • Save the downloaded .json file securely.

5. Link GA4 to BigQuery

  • In GA4, navigate to AdminBigQuery Links.
  • Click Create Link and select your BigQuery project.
  • Confirm your selection.

6. Connect BigQuery to PackDigital

  • In PackDigital Admin, navigate to Store > Settings > Integrations.
  • Click Create New Integration and select BigQuery.
  • Provide:
    • GCP Project ID (e.g., g4a-bigquery-pack-data)
    • Dataset Name (e.g., analytics_GA4PROPERTYID)
    • Service Account JSON File (paste the JSON key from Step 4)

Example JSON Service Account Key:

{
  "type": "service_account",
  "project_id": "g4a-bigquery-pack-data",
  "private_key_id": ".....",
  "private_key": "....",
  "client_email": "pack-bigquery-access@g4a-bigquery-pack-data.iam.gserviceaccount.com",
  "client_id": "XXXXX",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/pack-bigquery-access%40g4a-bigquery-pack-data.iam.gserviceaccount.com",
  "universe_domain": "googleapis.com"
}
  • Click Save.

Was this page helpful?