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.

For more information on how to use audiences please refer to the Google Analytics 4 documentation.

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

Capture_d_e_cran_2022-04-13_a__12.05.40.png

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”.

Capture_d_e_cran_2022-04-13_a__12.11.33__1_.png

OAuth credentials

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.

Capture_d_e_cran_2022-04-20_a__17.47.03.png

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.

Capture_d_e_cran_2022-04-20_a__17.51.15.png
  • 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”.

Capture_d_e_cran_2022-04-20_a__17.57.45__1_.png
  • Click “Add or remove scopes

  • Tick the “.../auth/userinfo.email” scope. Validate by clicking the “Update” button.

  • Click “Save and continue”.

Capture_d_e_cran_2022-04-20_a__18.02.53.png
  • Add your email address (the one used to connect to GCP) as a test user. Click “Save and continue”.

Capture_d_e_cran_2022-04-20_a__18.16.00.png
  • 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

Capture_d_e_cran_2022-04-13_a__12.20.45.png
  • 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.

credentials_organizationId_0_project_innovation-183314_organizationId_0_project_innovation-183314__1_.png
  • 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).

Capture_d_e_cran_2022-04-13_a__13.28.58.png

Give Google Analytics access rights to your OAuth Credentials

  • 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

Capture_d_e_cran_2022-04-13_a__13.38.28.png
  • 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.

Capture_d_e_cran_2022-04-13_a__13.45.51.png
Capture_d_e_cran_2022-04-13_a__13.49.09.png
  • You are redirected to the Oauth Playground, Step 2. Click “Exchange authorization code for tokens

Capture_d_e_cran_2022-04-13_a__13.51.39.png
  • Refresh token” field is now populated, copy and save the content of the field.

Capture_d_e_cran_2022-04-13_a__13.52.31.png

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

Capture_d_e_cran_2022-06-30_a__15.25.50.png
  • 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.

Capture_d_e_cran_2022-04-13_a__13.59.35.png
    • 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.

oWi6IVELOCYZB580HP3TvA5AFaZ67E7Tt3UD.png
    • 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 [email protected]

Always happy to help!

Last updated

Was this helpful?