Skip to content

Google Analytics

Ttoolab can push experiment exposure and conversion data to window.dataLayer, making it available to Google Tag Manager and Google Analytics 4.

When the GTM events integration is enabled for your project, the Ttoolab pixel automatically pushes dataLayer entries on:

  • Exposure — when a visitor is assigned to experiments ($exposure)
  • Conversion — when you call ttoolab.track() with a custom event

No extra code is required on your site beyond the standard pixel installation and GTM container.

  1. Open Integrations → Google Analytics in the Ttoolab dashboard.
  2. Connect your Google account (OAuth) if you want GA4 property linking for dashboard metrics.
  3. Enable GTM dataLayer events for your project.

The SDK reads integration settings from the bootstrap response and pushes events when gtmEventsEnabled is true.

Exposure event

window.dataLayer.push({
event: "ttoolab_exposure",
ttoolab_test: "ttoolab_test",
ttoolab_experimentName: "Hero CTA Test",
ttoolab_variationName: "Variant B",
ttoolab_experimentKey: "hero-cta-test",
ttoolab_experimentId: "EXPERIMENT_ID",
ttoolab_variantKey: "variant-b",
ttoolab_variantId: "VARIANT_ID",
ttoolab_isControl: false,
ttoolab_eventName: "exposure",
ttoolab_eventType: "exposure"
});

Conversion event

window.dataLayer.push({
event: "ttoolab_conversion",
ttoolab_test: "ttoolab_test",
ttoolab_experimentName: "Hero CTA Test",
ttoolab_variationName: "Variant B",
ttoolab_experimentKey: "hero-cta-test",
ttoolab_experimentId: "EXPERIMENT_ID",
ttoolab_variantKey: "variant-b",
ttoolab_variantId: "VARIANT_ID",
ttoolab_isControl: false,
ttoolab_eventName: "purchase",
ttoolab_eventType: "conversion",
ttoolab_revenue: 99.90
});

One dataLayer entry is pushed per active assignment.

Create a trigger in GTM:

  • Trigger type: Custom Event
  • Event name: ttoolab_exposure or ttoolab_conversion

Create GA4 Event tags that map Ttoolab fields to GA4 event parameters.

To compare variants in GA4 reports, register these custom dimensions in GA4 Admin:

| Dimension | Event parameter | | :-------- | :-------------- | | Experiment name | ttoolab_experimentName | | Variation name | ttoolab_variationName |

Without these dimensions, GA4 will receive events but per-variant breakdowns will be limited.

The Ttoolab dashboard can display GA4 metrics alongside experiment results when you connect via OAuth and select a GA4 property.

  • Confirm GTM events are enabled in Ttoolab project settings.
  • Verify your GTM container loads before or alongside the Ttoolab pixel.
  • Check window.dataLayer in the browser console after a page load with active experiments.
  • See Common issues.