# \[FE\&R] Send AB Tasty events to GA4

### Introduction

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

* Go to the **Integration Hub** > **Feature Experimentation**
* Create a **GA4 push** instance
* Enter **API secret** and **measurement ID**

<figure><img src="/files/a0S6URglsEhhB9y7HCh7" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

[^1]: <img src="/files/YQZRTZ6S0My5jlmsFXoX" alt="" data-size="original">

[^2]: <img src="/files/JywYDG4gWy9vmoNw5Zlt" alt="" data-size="original">


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.abtasty.com/flagship-deprecated/integrations/fe-and-r-google-analytics/fe-and-r-send-ab-tasty-events-to-ga4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
