Google Analytics 4 Integration
This integration allows you to use your existing Google Analytics 4 setup to track events within FeaturesFlow. This is useful if you want to track events in Google Analytics 4 and use FeaturesFlow to split traffic and measure metrics.
Setup
To set up an integration with Google Analytics you need to enable BigQuery export of your GA4 data. It is likely that you already have it setup, but if you don't, you can follow the official guide (opens in a new tab).
Once you have BigQuery export setup, you need to create a service account in Google Cloud Console and grant it access to the BigQuery dataset. This can be done with following steps:
- Log in to your Google Cloud console.
- Open the Navigation menu.
- Hover over
IAM & Admin
and selectService Accounts
from the submenu. - Click
CREATE SERVICE ACCOUNT
in the Service Accounts header. - Under Service account details, provide an account name, ID, and optional description.
- Click
CREATE
. - Under Service account permissions, assign the following role:
BigQuery Job User
(roles/bigquery.jobUser). - Click
CONTINUE
. - Click
CREATE KEY
to generate a JSON private key. A file will be downloaded to your computer. You'll use this file to connect to FeaturesFlow.
Almost done, the only thing left to do is to find your GA4 Property ID. You can find it in the GA4 admin panel under Property settings > Property details
.
Once you have all the necessary information, you can go to the FeaturesFlow dashboard and create a new Google Analytics 4 integration. You will need to provide the following information:
- JSON private key (the one you generated inside GCP console)
- GA4 Property ID
After you have created the integration, you should be able to see a list of events that are coming from GA4. You can use these events in your metrics and create experiments based on them.
Setup within code
In order to leverage the Google Analytics 4 integration, you need to connect GA4 client_id
with FeaturesFlow identifier
. This is supported in client side SDKs - React and Javascript/Typescript SDKs.
Retrieve GA4 client_id
and set it in FeaturesFlow
const { setGa4ClientId } = useFeaturesFlow();
useEffect(() => {
gtag('get', 'YOUR_MEASUREMENT_ID', 'client_id', (clientId) => {
if (typeof clientId === 'string') {
setGa4ClientId(clientId)
}
})
}, [])