Google Analytics Integration
The Google Analytics integration sends experiment assignment events to Google Analytics 4 (GA4) using gtag(). Once connected, every time a visitor is enrolled in an experiment, A vs B fires a GA4 custom event with the experiment and variation details. You can then use GA4's Explore tool to build custom reports segmented by experiment variation.
Setup
Go to Project Settings > Integrations
Enable Google Analytics 4
Enter your Measurement ID (optional)
G-XXXXXXXXXX. This is optional — if you leave it blank, the snippet will auto-detect an existing window.gtag instance on the page and use it. If you have already installed GA4 on your site (which you almost certainly have if you are enabling this integration), auto-detection is the easiest path.Save
What is sent to GA4
When a visitor is enrolled in a variation, A vs B calls:
1gtag('event', 'avsb_experiment', {2 experiment_id: 'exp_abc123',3 experiment_name: 'Homepage Hero Test',4 variation_id: 'var_xyz789',5 variation_name: 'Variation B',6 event_name: 'experiment_viewed'7});The event name is avsb_experiment by default. This can be customized in the integration settings if you prefer a different name.
Viewing in GA4 reports
After the integration has been running and collecting data for at least 24 hours (GA4 processing delay), you can find experiment data in GA4:
- In GA4, go to Explore and create a new Free Form exploration.
- Add Event count as a metric.
- In the Dimensions panel, search for Event parameterand add
experiment_nameandvariation_nameas dimensions. - Filter by Event Name =
avsb_experimentto see only A vs B events.
You can also use these dimensions in existing reports to segment your conversion goals, funnels, and user behavior by experiment variation.
experiment_id, experiment_name, variation_id, and variation_name as event-scoped custom dimensions.