How do I create audiences in Google Analytics 4 using an API? - google-analytics

Google Analytics 4 allows new custom audiences to be created:
I want to do this programmatically through a web API, but I can't see any documentation. Is it possible to create audiences in Google Analytics 4 using an API?

Google have confirmed that "the creation of audiences is not yet supported in Admin API" and have raised a feature request. They've not given a timeline for implementation but suggested following the Google Analytics API Notify group for future updates.
I need to remember that even after this feature is implemented in the GA Admin grpc API, it will also need to be supported in the .NET client library that I'm using, so there will take some additional time.

Not sure when added, but...
Web API:
https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties.audiences/create
.NET client:
https://googleapis.dev/dotnet/Google.Analytics.Admin.V1Alpha/latest/api/Google.Analytics.Admin.V1Alpha.AnalyticsAdminService.AnalyticsAdminServiceClient.html#Google_Analytics_Admin_V1Alpha_AnalyticsAdminService_AnalyticsAdminServiceClient_CreateAudience_Google_Analytics_Admin_V1Alpha_CreateAudienceRequest_Grpc_Core_CallOptions_

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.

Retrieve GA3 and GA4 data with same API?

So we are using Reporting V3 API in our custom dashboard to retrieve custom reports from multiple GA properties. Now some of our customers have GA4 properties which doesn't show up in properties list. Question is, to support both versions (GA3 and GA4) the only alternative now is to use Reporting V3 and Data API for different properties or did we miss something and there's one API which can be used for both GA versions?
There are two versions of Google analytics now Universal analytics and GA4 they are completely different and have different APIs designed for each one.
Google analytics reporting api allows you to access data from Universal analytics accounts.
Google Analytics GA4 is a completely different system and is not supported by the reporting api to access data behind a GA4 account you will need to use the Google analytics data api
there is also the Google analytics admin API which is the equivalent for the Management api for GA4. so if you want to be able to list a customers GA4 accounts you will need to use that api as well.
Note: The admin api is currently in alpha, and the data api is currently in beta. Take that into account before developing production applications using these apis.

Google Analytics Reporting API V3/V4 compatibility with Google Analytics 4 (GA4)

Today we use Google Analytics Reporting API V3 (core reporting API v3 using java SDK google-api-services-analytics-v3-revxxxx.jar) in our system to connect and get data from Google Analytics. For this, we need properties that are based on Universal Analytics (UA-xxxx). We use the service account approach for connecting to Google Analytics and fetching data.
From looking at the information available at https://developers.google.com/analytics/devguides/reporting it seems that we cannot use the v3 API with the new GA4 properties and we would have to use Data API V1. Is this correct? Any information around this would be helpful.
Yes, the data model of GA4 is completely different from that of Universal Analytics for which dedicated APIs are required.
To date, GA4 is still young and constantly evolving so many new improvements and features will come out in the near short future also from a programmatic point of view.
Anyway you can still create a Universal Analytics Property by 'show more option' button when you create a new one.

How to enable Advertising Features with Google Analytics API?

We couldn't find any code on Google Analytics Developers about how to enable Advertising Features for acccountId. Is it possible to make such request using API? If this isn't possible then gapi.client.analytics.management.remarketingAudience.insert({ seems pretty useless because you still need to do it manually. Any solution?
The API you mentioned is to create an audience segment.
You can't enable advertising features with API. You can enable it in Google Analytics interface or modifying code (in page or in GTM).

Google analytics using REST api

I want to add Google analytics manually on each pages and events in my website. Is there any ways to add Google analytics using REST api or any library in PHP. so i can track specific events of my website.
There is no REST API for Google Analytics. You will have to use one of the available libraries provided by Google.
To track particular events, you can use tag manager or simply use custom dimensions.
TL;DR, Google Analytics is great if all you ever use is their GUI dashboard. If you need API access, go with another service.
If you need to access analytics data programmatically, especially if you are using NodeJS, I suggest you use some other service besides Google. Their documentation is incredibly lacking, they try to pigeon-hole you into using a client library rather than steering you in the direction of a REST API, and authenticating is a nightmare. The new v4 API purportedly consists of a single endpoint that you need to query with a complex combination of HTTP body and query params. Again, documentation is nearly non-existent.

Resources