# Send Feature Experimentation Event to Google Analytics

The AB Tasty > GA4 Push Connector enables you to automatically send server-side experiment data from AB Tasty’s Feature Experimentation platform to Google Analytics 4 (GA4). This integration allows you to analyse how specific feature flags and variations impact your key metrics directly within GA4, without requiring client-side tracking.

Once configured, the connector pushes campaign and variation identifiers as custom events in GA4 whenever a decision is made for a visitor. This ensures consistent experiment tracking across both platforms, enabling more unified reporting and deeper behavioural insights.

{% hint style="warning" %}
**Visitor ID requirement**\
To make this integration work, you must pass the correct GA4 user identifier when calling the Decision API.

What you must do\
• Set a user ID in GA4 if you use your own identifier, for example:\
`gtag('set', { 'user_id': '12345' });`\
• Or retrieve the GA4 client ID using:\
`gtag('get', 'G-XXXXXXX', 'client_id', (clientId) => { console.log('Client ID:', clientId); });`\
• Call the Decision API with this same visitor ID, otherwise, the hit won’t be sent to the third party
{% endhint %}

### How-to

{% stepper %}
{% step %}

#### On Google Analytics: create Custom events on GA4

* Go to **Admin** → **Data Display** → **Custom definitions**
* Create a custom dimension for:
  * flagship\_campaign[^1]
  * flagship\_variation[^2]
    {% endstep %}

{% step %}

#### On Google Analytics: generate an API key

* Go to **Admin** → **Data streams** → **Measurement Protocol API secrets**
* Generate **an API key**
  {% endstep %}

{% step %}

#### On AB Tasty: create a GA4 connector

<figure><img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FRWfoZSKKPuhZNyT4gHBE%2Fimage.png?alt=media&#x26;token=669680e4-7e26-4870-b125-ddf5d4d25cfc" alt=""><figcaption></figcaption></figure>

* Go to the [**Settings > Integration Hub > Feature Experimentation Tab**](https://app2.abtasty.com/settings/integration/integration-hub?page=feature-experimentation)
* Create a **GA4 push** instance
* Enter **API secret** and **Measurement ID**

  * **Measurement ID :** It is the unique ID of a data stream (i.e. one of the data sources that provides data to your property). To retrieve your GA Measurement ID go to the Google Analytics interface and click **Admin>Property>Data Streams> Web and choose your data stream**. GA Measurement ID appears at upper right. More information [here](https://support.google.com/analytics/answer/9539598?hl=en).

  ![](https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FF7dIw5E6zTTcL1kbWxSD%2F0e9a7f2bb3785ec2cb01a5577210e595.png?alt=media\&token=05a84678-4ecc-4f53-856e-722484277cf5)
  {% endstep %}
  {% endstepper %}

[^1]: <img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FA7hDEKaUZhlbmLWSHYqB%2FFlagship%20Campaign.png?alt=media&#x26;token=cc7aba5d-a910-44b5-8237-1ddec6525706" alt="" data-size="original">

[^2]: <img src="https://2350286830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6Yw9IRJ6KbbucQPwZUCZ%2Fuploads%2FrkIfM2gaxRuLtv5J8KvA%2FFlagship%20Variation.png?alt=media&#x26;token=1e78e721-cfdc-47ac-b3f7-9ce60da8e594" alt="" data-size="original">
