Google Analytics integration (pull audiences)
Google Analytics integration (pull audiences)
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 audiences targeting, you need to push the Flagship Visitor ID in a user property for every session.
Our integration will then list the value of this user property for the different existing audiences through Google Analyticsās API. Then audiences and their composition are pushed to Flagship at the beginning of the next day.
Thus, the Google Analytics 4 integration set up process is taking place on several platforms :
Google Cloud Platform: to create the credentials to access Google Analytics data.
Google Analytics 4: to set up the collection of the Flagship Visitor ID
Flagship: to effectively set up the integration
An email account with admin access to Google Analytics 4 account is required to complete the setup
Create the credentials on Google Cloud Platform
To access Google Analytics 4 API programmatically we need to have credentials with granted accesses. Those are OAuth type of credentials and are created within the Google Cloud Platform.
Access a GCP project
Go to the Google Cloud Platform console
Select an existing project or create a new one. (Documentation to create a new project)
Activate the Google Analytics 4 API
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 it will be the case). The OAuth consent screen is the screen that will appear when you will give access right 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, email address: enter your email address (the one used to connect to GCP)
Other fields are optional, click āSave and continueā.
Click āAdd or remove scopesā
Tick the ā.../auth/userinfo.emailā scope. Validate by clicking the āUpdateā button.
Click āSave and continueā.
Add your email address (the one used to connect to GCP) as a test user. Click āSave and continueā.
You are at the summary screen, the OAuth consent screen is now ready and you proceed to the OAuth Credentials creation step.
OAuth Credentials creation
Open the console left side menu and select APIs & services
On the left, click Credentials>Create Credentials>OAuth client ID
Select āWeb Applicationā as the Application type. Enter a descriptive name of your choice e.g. āGA4 to Flagship Audience bridgeā.
Under āAuthorised redirect URIsā add āhttps://developers.google.com/oauthplaygroundā
Other fields are optional, click āCreateā to finalise 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).
Give Google Analytics access rights to your OAuth Credentials
Go to the Google OAuth Playground
Open the configuration panel and tick the āUse your own OAuth credentialsā. The āOAuth Client IDā and āOAuth Client secretā fields appear.
Fill the āOAuth Client IDā and āOAuth Client secretā fields with your own (saved from the previous OAuth Credentials step)
In the left panel, Step 1 āSelect and authorize APIsā, search for āAnalytics Reporting API v4ā and tick the 2 items underneath ("https://www.googleapis.com/auth/analytics" and "https://www.googleapis.com/auth/analytics.readonly")
Click āAuthorize APIsā
The Google Access Right interface appears : select the account with which you have access to the Google Analytics property and then click āauthorizeā to grant access.
You are redirected to the Oauth Playground, Step 2. Click āExchange authorization code for tokensā
āRefresh tokenā field is now populated, copy and save the content of the field.
Congratulations you now have all the required information to set up the integration on AB Tasty interface (see next step).
For more information on Oauth Playground please refer to this documentation.
For more information on Oauth 2.O please refer to this documentation or this documentation.
Enable the integration on Flagship
In the Flagship integrations settings you have different field to fill in to set up the integration :
Property ID : it is the unique ID of your GA4 property. To retrieve your Property ID go to the Google Analytics interface and click Admin>Property>Property Settings. Property ID appears at upper right. More information here.
GA 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.
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 paste the value saved from the previous steps
Refresh Token: part of the credentials to be able to access Google Analytics Data. Copy paste the value saved from the previous steps
Configure the custom definition on Google Analytics 4
You need to push the Flagship Visitor ID in a user property named āflagship_visitor_idā. Naming is very important because it is what will be pushed back to Flagship.
The user property āflagship_visitor_idā needs to be pushed for every session. This can be achieved thanks to a dedicated event for exemple.
Set the user property:
In the Google Analytics 4, left panel, click āConfigureā then āCreate custom dimensionsā
Enter the āDimension nameā you want to display in Google Analytics 4 e.g. āFlagship Visitor IDā
Select āUserā as the scope
Enter a description (optional)
Enter āflagship_visitor_idā as the āUser property
Click āSave
Congratulations, integration is now setup and you can target your Google Analytics 4 Audiences with Flagship!
For information on how to use the audiences, please refer to this documentation.
ā Good to know: Technical specifications
Audiences will be refreshed daily
The flagship_visitor_id is used to achieve user matching. It needs to be collected for every session as a user property and the naming must be respected.
For the audiences to be used in Flagship (once exported from Google Analytics 4), we need to match at least one user i.e. empty audiences will not be displayed.
For the audiences to be visible in Flagship 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 Flagship).
Need additional information?
Submit your request at product.feedback@abtasty.com
Always happy to help!
Last updated
Was this helpful?