Define Google Analytics 4 custom dimensions via API - google-analytics

Is there a way to programmatically define custom dimensions using the Google Analytics Admin API (that works with GA4)?
I'm talking about defining the dimensions ahead of time so I can send them along with events, which is what you'd manually do in the Google Analytics user interface (under All events > Manage Custom Definitions). This is what I'd like to do programmatically. Once they're defined, sending these custom dimensions along with tracking events is easy enough (using gtag).
Apparently, this was possible in the previous version of the API, but that API says that it "does not support GA4 properties".

You already can programmatically define/create custom dimensions and metrics with the Google Analytics Admin API for GA4 properties.
Custom dimensions
Can be created with this method providing:
description
displayName
parameterName (it hasn't need to exist beforehand)
scope (User or Event)
Custom metrics
Can be created with this method providing:
description
displayName
measurementUnit
restrictedMetricType
scope (Metric_Scope_unspecified or Event)
Warning from Google: This is an early preview version of the API and
is subject to change. While we will try to notify you of upcoming
changes, you should expect to encounter breaking changes before the
APIs are publicly released.

Jan,
You are correct that the Google Analytics Management API V3 cannot be used to configure GA4 properties. The Analytics Admin API V1, which supports GA4, does not currently have methods to create custom metrics/dimensions.
I will update this question once we have more information on when this feature can become available.
Thanks,
Ilya
The Google Analytics Team

Related

Is the GA User Activity API compatible with GA4?

Is it possible to retrieve user's data from a GA4 property using the User Activity API (https://developers.google.com/analytics/devguides/reporting/core/v4/user-reporting)?
I have checked the documentation but have not found anything so far. Some endpoints of the v4 API explicitly display a warning saying it is not compatible with GA4, but this User API does not display such warning.
no it is not as stated at the top of the page for the Reporting api Overview there for it apply sto the full Reporting API v4.
Note: This API does not support Google Analytics 4 (GA4) properties. Please use the Google Analytics Data API to access the new reporting features for GA4 properties.
As far as i can see there is no equivalent in GA4 yet.
Note: I pinged the team to have them add the quote to the top of that page as well.

How to create custom alert in Google Analytics 4

I want to create a custom alert in Google Analytics according to this guide
But this functionality is available only for Universal Analytics properties. And I can't find the custom alerts section for my GA4 properties as well as for Firebase Analytics property. There is a similar thing - Custom Insights but looks like it's not possible to select your own events there as trigger. And I need these alerts for data coming from mobile apps (they are using Firebase Analytics). Is there any workaround, is it possible to create a custom alert for GA4?
Why do I need a custom alert in the first place? I want to have a notification when multiple users are not finishing the sign-up process.
At the moment, there are no ways to do it in interface. You can eventually build a your customized system that reads data in BigQuery every day and sends you an email based on the rules you have defined.

How to add Google universal analytics to Google analytics 4 only?

I have create a Google analytics 4 property and been running and gathering data for while now.
I need some external tools to integrate with it and I saw developers reporting that GA4 does not have an API yet, so it does not support any integrations.
I saw that you can create a dual UA and GA4 property but I was unable to find how to add UA to existing GA4 property.
In short: How do I add universal analytics view without loosing any data or integrate with external tools i.e. slack bot posting regular updates? (work around with big Query?)
GA4 does have an API. You can use the Google Analytics Data API v1 to fetch analytics data. The developer's site for this API has more information: https://developers.google.com/analytics/devguides/reporting/data/v1. The API is currently available at an Alpha (preview) stability. The API will be entering Beta shortly.
When you read about creating dual Property it means tracking with both GA4 and Universal Analytics separately. They are 2 different scripts that track data in different platforms with different model.
Therefore you can create a new Universal Analytics Property in your Google Analytics Account and insert that code in the pages of your site, however it will start tracking from that moment on, you cannot have the history, both because you cannot transport data from a Property to the another (even if they were 2 Properties of the same type), and because GA4 has a completely different data collection model.
In any case, from the moment you start tracking with Universal Analytics then you can query the data with the relative API (i.e. Analytics Reporting API).

Firebase+GTM SDK - accessing GA tracker Client ID

I am implementing v5 Firebase+GTM SDK with the sole purpose of tracking the events in Google Analytics.
I can't seem to find a way to access GA Client ID (using previous versions of GTM SDK, I was able to access tracker object and get or set the value).
I am talking about this value:
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid
Is there a way to reach to GA object hidden inside FIRAnalytics?
Yeah, I don't think tracker object is surfaced.
What you can do is to generate your own clientID (a simple guid would do) and in Google Tag Manager configure a tag to set it as a field. This way you will fully control the cliend id (&cid) and therefore change it as you see fit
This is not possible as of today, since Firebase does not expose data via a REST API. There is no API to even pass on the GA client ID.
From GTM's side of things, that is again a closed system since the data from Firebase is intercepted by GTM but cannot be pulled out or tweaked before it is passed to GA.

Google Analytics API: Create a new profile

Is it possible to create a new profile via the Google Analytics API?
This way we can automatically register the tracking when we have new landingpages created.
I am curious if anyone is working with an automated way of automatically setting up GA tracking.
Yes! The Google Analytics Management API has changed... As you can see from the documentation, available methods for profiles are delete, get, insert, list, patch and update.
You can even insert new Web Properties, but beware of the 20 properties per account limit.
No - the Google Analytics Management API is read-only. As you can see from the documentation, the only available method for accounts, properties, and profiles is list.

Resources