Create segments in GA4
Use Google Analytics 4 (GA4) to capture and analyze traffic data across your websites and applications.
Important
Starting July 1, 2023, GA4 will replace standard Google Universal Analytics (UA), which will no longer process data. For more information, see Introducing Google Analytics 4 (GA4).
You must set up an integration between Optimizely Web Experimentation and GA4 to create segments for Optimizely Web Experimentation within GA4. For information on setting up this integration, see the following articles:
- Integrate Google Analytics 4 (GA4) – The built-in GA4 integration.
- Create a custom integration for GA4 – Custom GA4 integration without GTM. Choose this option if you do not want to use the built-in integration.
- Create a custom integration for GA4 using GTM – Custom GA4 integration using GTM. Choose this option if you want to use GTM and do not want to use the built-in integration.
After your integration between Optimizely Web Experimentation and GA4 is set up, you can create segments for Optimizely Web Experimentation within GA4.
Note
It can take up to 48 hours before values become available in Google Analytics 4 (GA4) so that you can create dimensions/segments with them.
Create segments in GA4
Complete the following steps to create segments for Optimizely Web Experimentation in GA4:
Step 1. Create custom dimensions
- Go to Admin > Custom definitions > Create custom dimensions.
- Complete the following fields on the New custom dimension page:
- Dimension name – Enter your desired name (such as Optimizely experiment).
- Scope – Ensure this is set to Event.
- Description – Enter an optional description.
- Event parameter – Select
Experiment
.Important
If you are using the custom GA4 integration, select
optimizely_experiment
for the Event parameter.
- Repeat steps 1 and 2 for
Variation
.Important
If you are using the custom GA4 integration, select
optimizely_variant
for the Event parameter. - Repeat steps 1 and 2 again for
Campaign
. - (Optional) If you want to exclude holdback visitors from your reports in GA4, create a custom dimension for
LayerHoldback
.Note
For more information on Optimizely Web Experimentation holdback, see Holdback: Measure overall impact.
Step 2. Create an exploration and add segments
- Go to Explore and select an exploration type (for example, Free form).

- In the Variables pane on the left, click the plus icon next to SEGMENTS.
- On the Build new segment page, in the Create a custom segment section, click User segment.

- Enter the name of the segment (specifying the specific experiment/variant for which you are creating this segment).
- Expand the Add new condition dropdown list and click Custom > Optimizely experiment.

- Click ADD FILTER.

- Ensure the Condition is set to contains and then select the experiment/variant for which you want to create the segment. The image below is an example for Optimizely experiment.

- Click SAVE AND APPLY.
- Repeat step 2 through step 8 for Optimizely variant.

Updated 3 days ago