You have events in GA4 and you’d like to forward them to Optimizely Feature Experimentation?
You’ve come to the right place.
Note: Google Tag Manager (GTM) is required to use this integration. This integration is the counterpart to the GA4 to Optimizely Web events integration recently discussed.
Step 1: Download & import the GTM container
Head to this link and download the JSON file.
Then head to Google Tag Manager and import the container. If you don’t know how to import a container you can follow this tutorial here from Google.
Upon importing, make sure to pick the Merge option.

When a GA4 datalayer push is fired, GTM will pick it up and forward this event to Optimizely.
Step 2: Set some basic configuration
Once imported, a few new tags will be created in GTM. One of them will be called [GA4 to Optimizely FX] Initialisation Code

Click on it and we’ll need to make a few edits. I promise this won’t be very difficult.

In the code block that appears, we need to fill in a few pieces of information from line 22 to line 27, mainly:
- Your account_id: you can find this on this page.
- The user_id you are using in your FX implementation. Typically this is the value you’re setting when calling Optimizely’s SDK createUserContext. In this example we use a self-generated optimizelyEndUserId cookie.
- The environmentKey: you can find this inside Settings->Implementation in Optimizely. Note that all events you’ll want to forward from GA4 to Optimizely will need to exist with the same event name in this environment and project.
Once done, save the changes. That’s it!