G4 & AB tasty
Google Analytics is an analytics service that enables you to measure traffic and engagement across your websites and apps. Google Analytics 4 is the latest version of Google Analytics.
The Google Analytics 4 integration allows you to receive the audience created in Google Analytics, and to target them with AB Tasty.
Good to Know 💡- Google Analytics 4 Audiences
Audiences are groups of users defined by a chosen set of criteria. Dimensions, metrics, and events can be used to segment practically any subset of users.
To achieve Google Analytics 4 audience targeting, we push our unique identifier (AB Tasty visitor ID) into a user property for every session and then list the value of this user property for the different existing audiences through Google Analytics API. The following day, audiences and their makeup are sent to AB Tasty.
Thus, the Google Analytics 4 integration setup process is taking place on several platforms :
- Google Cloud Platform: to create the credentials to access the Google Analytics data
- Google Analytics 4:to set up the collection of the AB Tasty visitor ID
- AB Tasty: to effectively set up the integration
Heads up⚡
An email account with admin access to Google Analytics 4 accounts is required to complete the setup.
Requirements
Because we must send our abtasty_visitor_id (as a user property - see later in this documentation) and because this integration is with GA4, your website must have a dataLayer (at least only gtag.js or full GTM).
On your website, this command should be available:
window.google_tag_manager
The first key corresponds to the measurementID you want to send some native hit into GA4. This measurementId must be entered in the configuration of the integration in AB Tasty (see later).
Integration
Creating the Credentials on the Google Cloud Platform
We need credentials with granted access to access Google Analytics 4 API programmatically. Those are OAuth types of credentials and are created within the Google Cloud Platform.
Accessing a GCP Project
To access a GCP Project, follow the steps below:
- Access the Google Cloud Platform console.
- Select an existing project or create a brand new one. (Documentation to create a bespoke project)
Activating the Google Analytics 4 API
To activate the Google Analytics 4 API, follow the steps below:
- In the Google Cloud Platform interface, open the console left side menu and select APIs & services.
-
On the left, click Library, search for the “Google Analytics Data API” and select it. Click Enable.
OAuth Credentials
OAuth Consent Screen Setup
Before creating the OAuth credentials, you need to check that you have an OAuth consent screen setup. If you don’t, you need to set it up (if you just created the GCP project, that will be the case). The OAuth consent screen is the screen that will appear when you grant access to your credentials.
Check the OAuth consent screen: Open the console left side menu and select APIs & services: click Credentials > Create Credentials > OAuth consent screen. If you see an app already exists here, it means the consent screen is set up, and you can proceed to the next step: OAuth Credentials creation.
If there is no existing app, you will see the first step of the creation process:
-
Choose the Internal option if you are a Google Workspace user, otherwise choose External. Click the Create button
- Under App information, enter an App name. It can be something similar to the project name.
- User support email: enter your email address (the one used to connect to GCP).
-
Developer contact information, and email address: enter your email address (the one used to connect to GCP).
All other fields are optional. -
Click Save and continue
- Click Add or remove scopes.
- Tick the.../auth/userinfo.email scope. Validate by clicking Update.
-
Click Save and continue
-
Add your email address (the one used to connect to GCP) as a test user. Click Save and continue.
- You have reached the summary screen, click Back to dashboard
- On the dashboard of the created Oauth consent screen, you should switch the Publishing status to In production by clicking the Publish app button.
The OAuth consent screen is now ready, and you proceed to the OAuth Credentials creation step.
OAuth Credentials Creation
To create OAuth credentials, follow the steps below:
- Open the console left side menu and selectAPIs & services.
-
On the left, clickCredentials > Create Credentials > OAuth client ID.
- Select Web Application as the Application type. Give the bridge a descriptive name such as e.g. “GA4 to AB Tasty Audience bridge”.
-
Under Authorised redirect URIs add “https://integrations-oauth.abtasty.com/ga4/callback”.
All other fields are optional. - Click Createto finalize the OAuth credentials creation.
-
A confirmation message appears, it also displays the Client ID and the Client Secret of your Oauth credentials. Copy-paste and save for later (you can also download them in a .json format).
Congratulations! You now have all the information you need to set up the integration on AB Tasty (see next step).
Enabling the Integration on AB Tasty
To enable the integration on AB Tasty, follow the steps below:
- Access Integrations > Integration Hub > Pull.
- Search for and select Google Analytics 4.
- Click Setup connector.
- Give a name to your connector so you can easily retrieve it.
- Input your Measurement ID
- Click Authorize and Create.
You are redirected to another setup screen. You have different fields to fill in to set up the integration:
- Connector Name: the name of the connector, you can name it as you want. We recommend giving it an explicit e.g. "GA4 - propertyXX" (here propertyXX would be the id of the property you will pulling audiences from.
-
Property ID: it is the unique ID of your GA4 property. To retrieve your Property ID, access the Google Analytics interface and click Admin > Property > Property Settings. Property ID appears at the upper right. For further information, please refer to this article.
-
GA Measurement ID: it is the unique ID of a data stream (i.e. One of the data sources that provides data for your property). To retrieve your GA Measurement ID, access the Google Analytics interface and click Admin > Property > Data Streams > Web, and choose your data stream. GA Measurement ID appears at the upper right.
For further information, please refer to this article.
- Client ID: part of the credentials to be able to access Google Analytics Data (see previous steps).
- Client secret: part of the credentials to be able to access Google Analytics Data. Copy and paste the value saved from the previous steps.
2. Once all fields are filled, click Get refresh token
3. You are redirected to Google's authorization screen: select the account with which you have access to the Google Analytics property and then click Authorize to grant access. This will authorise AB Tasty pull data (audiences from your GA4 API).
4. You are redirected to AB Tasty's settings interface, and you can see the GA4 connector activated. If you click on the connector, you will see all the fields filled, including the refresh token.
For further information on Oauth 2.O please refer to this documentation or this documentation.
Congratulations! The GA4 pull integration is now set up on AB Tasty's side. You now have to configure GA4 in order to make it work (see next step).
Configuration
To push the AB Tasty Visitor ID we use a user property named abtasty_visitor_id that is sent with an event named abtasty. Therefore, we need to set up the collection of custom definitions on GA4's interface.
The AB Tasty Visitor ID is then pushed back to AB Tasty for targeting.
-
In the left panel, click Configure>Create custom dimensions.
- Enter the Dimension name you want to display in Google Analytics 4 e.g. “AB Tasty Visitor ID”.
- Select User as the Scope.
- Enter a description (optional).
- Enter abtasty_visitor_id as the User property.
-
Click Save.
Congratulations, integration is now set up, and you can view your Google Analytics 4 Audiences with AB Tasty. For global information on how to build a targeting segment, please refer to how to create a segment.
Good to Know 💡- Sending our abtasty_visitor_id
How do we push our abtasty_visitor_id?
- Until September 2024, we always sent this specific id into GA4 thanks to this API call (url : 'https://www.google-analytics.com/g/collect'; We added the abtasty_visitor_id, the sessionId, the clientId as query params. The name of the event was “abtasty”. This method could generate some troubles (especially for users which have a GTM server side, with their own custom url).
- Since that date, we use your dataLayer in order to send the abtasty_visitor_id as user_property and thanks to a new event, which is abtasty_pull.
- This event will be visible on the Google Analytics 4 interface (you can ignore it) and the abtasty_visitor_id will be visible too.
Example of sending of abtasty_visitor_id:
Good to Know 💡- Technical Specification
- Audiences will be refreshed daily
- AB tasty pushes the abtasty_visitor_id to Google Analytics 4 with the abtasty event, thus once the integration is set up the abtasty event and abtasty_visitor_id will be visible on the Google Analytics 4 interface.
- The abtasty_visitor_id is used to match users.
- For the audiences to be used in AB Tasty’s segment builder (once exported from Google Analytics 4), we need to match at least one user i.e. Empty audiences will not be displayed in the segment builder.
- For the audience to be visible in the segment builder, you need to wait 24 hours after the setup of the integration. This is due to the different synching mechanisms between the tools (data collection by Google Analytics 4 and then the data import from Google Analytics 4 to AB Tasty).