Skip to content

Google Analytics 4

Google Analytics 4 (GA4) is the latest version of Google's analytics platform, designed to provide businesses with detailed insights into user behavior across websites and apps. GA4 offers advanced features such as event-based tracking, cross-platform insights, and machine learning-powered predictions, making it a powerful tool for data-driven decision-making.

The Google Analytics 4 application allows you to retrieve and analyze metrics from your GA4 properties, giving you insights into user interactions and engagement.

To use our Google Analytics 4 connector, it is necessary to configure a service account in the same project as your GA4 project. It's very simple to create. Go to your GCP console or click this link: https://console.cloud.google.com/ Then, in the upper left corner, select the project for which you want to retrieve your logs. In the search bar, type "Service Accounts" and select it. You can either use the default account or create a new one. To create a new one, click "Create service account", give it a name and description as you wish, the most important thing is to give it the role Viewer in category "Allow this service account to access the project (optional)" so it can access your project and read your logs, you can add more options but it's optional for our Vault. Once created, select in "Actions" Manage Keys, you can now Add Key, Create Key and select JSON as the key type, you can now Create. It should download a JSON file, all you need to do now is to upload it into the JSON key in your Google Cloud Vault. You also need your GA4 property ID that you can find by typing "Property Details" in the search bar of Google Analytics, make sure to be in the right project.

Options

  • Name*: Just a simple label to find it easier in the SenHub's interface
  • Description: Description for your own usage only.
  • Vault: Select the appropriate vault for this resource from the list box.
  • Group: optional — assign this instance to a group to organise it within SenHub.
  • Property ID: The property ID of your GA4 project.
  • Category: Choose the metric category to retrieve (Users and sessions, User engagement, Conversions and events or E-commerce). The channels returned depend on this choice.
  • Time period: Choose the appropriate time period from the list box.

Example output

For the selected property, category and time period, the connector returns a Start Time timestamp followed by one channel per GA4 metric in the chosen category. The channels differ by category.

Category Users and sessions:

{
  "metrics": [
    { "channel": "Start Time", "value": 1725981405127, "unit": "ms" },
    { "channel": "activeUsers", "value": "4200", "unit": "count" },
    { "channel": "newUsers", "value": "1350", "unit": "count" },
    { "channel": "totalUsers", "value": "5100", "unit": "count" },
    { "channel": "sessions", "value": "6800", "unit": "count" },
    { "channel": "sessionsPerUser", "value": "1.33", "unit": "count" },
    { "channel": "averageSessionDuration", "value": "185.4", "unit": "count" }
  ],
  "message": "Metrics successfully retrieved.",
  "status": "OK",
  "date": 1725981405127
}

Category User engagement:

{
  "metrics": [
    { "channel": "Start Time", "value": 1725981405127, "unit": "ms" },
    { "channel": "userEngagementDuration", "value": "742000", "unit": "count" },
    { "channel": "engagedSessions", "value": "3900", "unit": "count" },
    { "channel": "engagementRate", "value": "0.57", "unit": "count" }
  ],
  "message": "Metrics successfully retrieved.",
  "status": "OK",
  "date": 1725981405127
}

Category E-commerce:

{
  "metrics": [
    { "channel": "Start Time", "value": 1725981405127, "unit": "ms" },
    { "channel": "purchaseRevenue", "value": "12500.00", "unit": "count" },
    { "channel": "totalRevenue", "value": "13800.00", "unit": "count" },
    { "channel": "ecommercePurchases", "value": "240", "unit": "count" },
    { "channel": "purchaseToViewRate", "value": "0.031", "unit": "count" }
  ],
  "message": "Metrics successfully retrieved.",
  "status": "OK",
  "date": 1725981405127
}