I've faced a comparability problem while migrating from Reporting API V4 to Data API V1 (Beta). Some old (UA) metrics became not available.
Several of them are computable at client side.
For example:
avgSessionDuration(ga:avgSessionDuration) = userEngagementDuration(ga:sessionDuration) / sessions(ga:sessions)
pageViewsPerSession(ga:pageviewsPerSession) = screenPageViews(ga:pageviews) / sessions(ga:sessions)
The question is: How to obtain equivalent data for listed below UA metrics using Data API V1?
ga:uniquePageviews
ga:avgTimeOnPage
Universal analytics and GA4 are two totally different systems your not going to be able to convert a report. You need to make new reports designed for GA4.
GA4 does not have uniquePageviews or avgTimeOnPage
You should check API Dimensions & Metrics to find the current list of dimensions and metrics available with Ga4.
Remember Ga4 is Event based not page view based.
It seems to be available. check this page for GA4 equivalents:
https://developers.google.com/analytics/devguides/reporting/data/v1/migration-api-schema-mapping
Im getting the data succesfully by using:
Dimension: fullPageUrl
Metrics: eventCount, userEngagementDuration
Related
It looks like Google Analytics 4 API doesn't offer reporting to the minutes. The closest I can see in the Query Explorer is Date + Hour.
Is there a way to obtain data accurate to the minutes with GA4 reporting API?
One workaround could be to capture the hit timestamp as a custom dimension. Here's an example: https://www.simoahava.com/analytics/improve-data-collection-with-four-custom-dimensions/#4-hit-timestamp
Note that link I shared sets up a custom dimension for Universal Analytics, not GA4. So for GA4 you would need to capture it as an event parameter and then create the custom dimension in the GA4 interface.
Alternatively, you could enable the export to BigQuery and the following field is provided in the schema: event_timestamp
Google Analytics 4 Data API added three new dimensions today: dateHourMinute, minute, and nthMinute. This page lists all dimensions and metrics available in the API.
These dimensions are compatible with some but not all other dimensions and metrics. For example, minute is compatible with eventCount and activeUsers, but minute is not compatible with newUsers. We're adding a new API method to show which dimensions and metrics are compatible with other dimensions and metrics.
Thanks,
Brett
The Google Analytics Team
Not sure if there is a workaround but GA have said in April that they plan to add dateHourMinutes to GA4 API.
Currently, in my project "dev--sci" I do not see a third column with View Settings to get my view ID from (need this to call Google Analytics API).
I followed the directions from this stack overflow answer, which called for creating a new universal property. However, this appears to take me out of "dev--sci" altogether and create a new project called "views (UA-XXXXXX)", which does have the View Settings. But I need the view ID for my original "dev--sci" project, not this blank new one.
How do I get the view ID for my original project "dev--sci" and why doesn't it have the third view column? I believe it's b/c GA V4 doesn't have views, but then for some reason their API still requires it?
As you read in that post, GA4 does not have views, so if you are looking for a view ID to be able to use the APIs that require it in GA4, it means that you are using the wrong APIs, i.e. those that work with Universal Analytics (UA-XXXXX- XX).
GA4 uses a completely different data model from that of Google Analytics, for this reason the APIs to be used are different.
Here you can find some information about Google Analytics Data API V1 that provides programmatic methods to access report data in Google Analytics 4 (GA4) properties:
https://developers.google.com/analytics/devguides/reporting/data/v1
However, as you can see, this is an early preview version of the API and is subject to change:
Google Analytics (particularly version 4, "GA4") has various predefined events, each with its own parameters. E.g. the purchase event has an items parameter, which contains data such as item_id and item_name for each purchased item. JS code on a website can send these events and pass the extra data, and I can actually see the data in the "Analysis hub" in the Google Analytics interface.
Is there a way to also fetch this extra data using the Google Analytics Data API? There is a way to retrieve some predefined dimensions and also "custom dimensions" (via customEvent:parameter_name), but e.g. purchase item data doesn't seem to be a part of that.
Do I have to define custom dimensions (e.g. a purchasedProductId) and send them in addition to the items parameter, if I want to access this data via API?
Jan,
Ecommerce reporting is not yet supported in the Google Analytics Data API. I will update this question once I have more information about the timeline of this feature implementation.
Thanks,
Ilya
The Google Analytics Team
Can i create custom dimension or metric with google analytics Management API? (Or other API...)
On January 23, 2015 the Google Analytics team released a change allowing for the creating of custom dimensions and metrics via the Management API.
Custom dimensions and metrics in the Management API allow you to create, get, list, update and patch custom dimensions and metrics for a Google Analytics property.
It is split up into two sections of the api Custom dimensions and custom metrics.
Not sure what language you where using so I cant help you with any sample code. I suggest you check the documentation.
Nope. Full reference for the Management API is here.
It doesn't include custom dimensions. Would be nice though, I agree.
The Provisioning API lets you create accounts, but that is in closed beta to AdWords partners at the moment. But however an account is created, the Management API is the one that lets you edit features such as filters at the moment, so would be where custom dimensions/metric control should also sit when available.
The collection APIs then let you send data to your custom metrics and dimensions once you have created them in the admin section of your web property.
Custom Dimensions and Metrics can be created in php for sure https://github.com/google/google-api-php-client
$dimension = new Google_Service_Analytics_CustomDimension();
$dimension->setName('[name]');
$dimension->setScope('[scope]');
$dimension->setActive(TRUE);
$client->management_customDimensions->insert('[webPropertyId]', '[analytics-account]', $dimension);
"$client->management_customMetrics" can be used in a similar way for metrics.
Gathering Data
In order to send data Google provides collection APIs and SDKs.
Configuring Accounts
Google Analytics provides programmatic access and management to configuration data through the Management API and account creation capabilities through the Provisioning API.
Reading Data
Google Analytics provides a simple and powerful APIs to retrieve report data from Google Analytics.
To answer the OP: you create custom dimensions and metrics via the collection API.
Dimensions: Describe data
A dimension is a descriptive attribute or characteristic of an object that can be given different values. For example, a geographic location could have dimensions called Latitude, Longitude, or City Name. Values for the City Name dimension could be San Francisco, Berlin, or Singapore.
Browser, Exit Page, Screens, and Session Duration are all examples of dimensions that appear by default in Google Analytics. Dimensions appear all of your reports, though you might see different ones depending on the specific report. Use them to help organize, segment, and analyze your data. In some reports, you can add and remove dimensions to see different aspects of your data.
Metrics: Measure data
Metrics are individual elements of a dimension that can be measured as a sum or a ratio. For example, the dimension City can be associated with a metric like Population, which would have a sum value of all the residents of the specific city.
Screenviews, Page per Session, and Average Session Duration are examples of metrics in Google Analytics.
Dimensions vs Metrics: What’s the difference?
Definitions: Goals, Metrics, KPIs, Dimensions, Targets
Implemented a filter on a webservice to make gif calls to GA for tracking method calls.
During initial testing I set a custom variable that contained account information. But for some reason, after a few weeks the variable stopped coming through to standard reporting correctly.
A test gif url:
http://www.google-analytics.com/__utm.gif?utmwv=4.4sj
&utmn=230567348
&utmhn=localhost
&utmr=-
&utmp=http%3A%2F%2Flocalhost%2Fv2svrmng%2FServiceManagerV2
&utmac=UA-12345678-9
&utmcc=__utma%3D999.999.999.999.999.1%3B
&utmvid=0x6ffa39da7d6bd0c7
&utmip=127.0.0.0
&utme=8(Account)9(testaccount-99999)11(2)
The Account key seems to be read correctly but the testaccount-99999 value appears as (A
Is some sort of weird truncation occurring here?
The gif request is not a supported or documented API. You can only use it with the javascript library provided or other google libraries that communicate with Google Analytics.
The good news is that Universal Analytics is a new update to Google Analytics (currently in Public Beta) and it has a documented protocol to send data to GA using server side code like you want.
Read more about it and how to get into the Beta here:
https://developers.google.com/analytics/devguides/collection/protocol/v1/