Skip to content

Google Analytics 4 Integration

Google Analytics 4 (GA4) helps you understand how visitors engage with your website — from page views and clicks to conversions and user journeys. By integrating CustomerLabs with GA4, you can leverage enriched first-party data to improve goal tracking, funnel analysis, attribution modeling, and audience building.


Before connecting to CustomerLabs, you need a GA4 property and a Web Data Stream to obtain your Measurement ID. Skip this section if you already have both.

  1. Log in to your Google Analytics account.

  2. Click the Admin (gear) icon at the bottom of the left sidebar.

    GA4 Admin panel
  3. Click + Create and select Property.

    Create a new GA4 Property
    Enter property name and continue
  4. Enter the Property name, Timezone, and Currency, then click Next.

    Property details form
  5. Select your Industry category and Business size, then click Next.

    Business details
  6. Choose your Business Objective and click Create.

    Choose business objective
  7. On the “Start collecting data” screen, you can choose a platform or click Skip for now.

    Skip data collection platform selection

A Data Stream channels data from your website into your GA4 property and generates the Measurement ID you need in CustomerLabs.

  1. In the Admin section, go to Data collection and modificationsData Streams.

    Navigate to Data Streams in GA4 Admin
  2. Select Web as the platform.

    Select Web platform for data stream
  3. Enter your Website URL and a Stream name, then click Create and Continue.

    Enter website URL and stream name
  4. Open the newly created data stream and copy the Measurement ID (formatted as G-XXXXXXXXXX).

    Copy Measurement ID from the data stream

You now have everything you need to connect GA4 to CustomerLabs.


Step 1: Add GA4 as a Destination in CustomerLabs

Section titled “Step 1: Add GA4 as a Destination in CustomerLabs”
  1. Log in to your CustomerLabs account and navigate to Destinations from the left menu.

  2. Search for and select Google Analytics gtag.

    Select Google Analytics gtag from Destinations
  3. Enter a Destination ID and click Save and Enable.

    Save and Enable GA4 Destination
  4. Click Configuration settings.

    Go to Configuration Settings
  5. Click Sign in with Google to authenticate your GA4 property.

  6. Paste the Measurement ID you copied earlier into the Website Tracking ID field under Basic Settings.

    Enter GA4 Measurement ID in Basic Settings
  7. Click Save Changes.


Step 2: Server-Side Integration (Measurement Protocol)

Section titled “Step 2: Server-Side Integration (Measurement Protocol)”

The Measurement Protocol lets you send event data directly from your server to GA4 — useful for offline conversions, CRM events, and interactions that can’t be captured in the browser.

  1. Inside your data stream, scroll to Measurement Protocol API Secrets.

    Copy Measurement ID from the data stream
  2. Accept the terms and acknowledge to create API key secret.

    Measurement Protocol API Secrets section
    Create a new API Secret
  3. Click Create, enter a Nickname (e.g., “CustomerLabs Key”), and click Create.

    Enter API secret nickname
  4. Copy the Secret Value shown.

    Copy the generated API secret value
  1. In CustomerLabs, go to DestinationsGoogle Analytics gtagConfiguration settings.

  2. Under Advanced Settings, toggle ON the Enable GA4 Measurement Protocol option.

    Advanced Settings — Enable Measurement Protocol and Enhanced Ecommerce
  3. Paste the Secret Value into the API Secret field.

  4. Click Save Changes.


Enabling Enhanced Ecommerce sends additional product and transaction data to GA4 for standard e-commerce events, unlocking detailed purchase funnel reports.

Enable the Enhanced Ecommerce toggle in Advanced Settings.

Advanced Settings — Enable Measurement Protocol and Enhanced Ecommerce

User-ID Tracking assigns a consistent identifier to each user across sessions and devices, enabling more accurate cross-session reporting and audience segmentation in GA4.

Enable the User-ID Tracking toggle in Advanced Settings and set User Identify ID to Customerlabs user ID.

Advanced Settings — Enable Measurement Protocol and Enhanced Ecommerce

To measure the value of specific events (such as purchase revenue or lead value) in GA4 reports, you need to create Custom Metrics that map to the event parameters CustomerLabs sends.

  1. In GA4, go to AdminData displayCustom definitions.

    Navigate to Custom definitions in GA4 Admin
    Custom definitions - Custom metrics tab
  2. Click the Custom metrics tab, then click Create custom metric.

    Custom metrics tab
    Create custom metric button
    Custom metric creation form
  3. Fill in the details:

    FieldValue
    Metric nameA descriptive label (e.g., Purchase Revenue)
    Event parameterThe parameter CustomerLabs sends (e.g., value or ecomm_totalvalue)
    Unit of measurementSelect Currency for monetary values
    Configure the new custom metric
  4. Click Save.

  1. In GA4, navigate to ReportsEngagementEvents.

  2. Click the Edit (pencil) icon to customize the report.

    Edit the Events report
    Customize report panel
  3. Click MetricsAdd metric, and select your custom metric from the dropdown.

    Add metric panel
    Select the custom metric
    Custom metric selected
  4. Click Apply and save the report.

    Custom metric visible in the report

Google’s Consent Mode V2 helps you comply with EU consent policies. Based on user consent choices, Google dynamically adjusts how it stores and uses analytics and advertising data.

  1. Go to DestinationsGoogle Analytics gtagConfiguration settingsConsent Mode Configuration.

  2. Toggle Consent Mode ON.

    Consent Mode Configuration toggle
  3. Set default values for each consent parameter using the dropdowns. These defaults apply before a user makes a consent choice.

    Set default consent parameter values
    ParameterPurpose
    analytics_storageControls whether analytics cookies can be stored
    ad_user_dataControls whether user data can be sent to Google for advertising
    ad_personalizationControls whether data can be used for personalized advertising
  4. Client-Side Consent Initialization:

    • Using a Google-certified CMP: The CMP handles initialization automatically.
    • Not using a CMP: Toggle ON Client Side Consent Initialization so CustomerLabs sets the defaults.
    Client Side Consent Initialization toggle
  5. Click Save Changes.

Section titled “Updating Consent Preferences Programmatically”

When a user updates their consent choice through your banner, call the following function to pass the updated state to CustomerLabs:

_cl.trackConsent({
"ad_user_data": "granted",
"ad_personalization": "granted",
"analytics_storage": "denied"
});

All available parameters:

{
"ad_user_data": "granted",
"analytics_storage": "granted",
"ad_personalization": "granted",
"ad_storage": "granted",
"functionality_storage": "granted",
"personalization_storage": "granted",
"security_storage": "granted"
}

The Event Workflow controls which events CustomerLabs sends to GA4 and whether they go via the browser (client-side) or server (server-side).

  1. From the GA4 destination screen, click Setup Event Workflow.

    Click Setup Event Workflow
  2. Toggle ON the events you want to send either on client-side or server-side.

  3. To sync audiences with GA4, ensure the added_to_segment event is enabled under Server-side callbacks.

    Enable added_to_segment event for audience syncing
  4. Click Save Changes.