Google Analytics metadata for column compatibility - google-analytics

Does anyone know if the Google Analytics API exposes the compatibility data for selecting a set of dimensions and measures? For example, if I select the "ga:adGroup" dimension, then I can't select any of the Goal Completion dimensions. This compatibility seems to be based upon the data cubes that are defined in Google.
Is this list of what dimensions and measures are compatible with each other programmatically available from the Google API?

Related

where to find google analytics dimensions values

I'm trying to implement my own google analytics reporting UI where users pick metrics and dimensions and then pick the filters according to what the user have already chosen and my question is there any way to get all the dimensions values? for example the dimension "country" can take the value of all the countries(USA,Fance,etc...). I've did some research on google but found nothing. any help is appreciated!
I would suggest using something like Analytics Edge extension for Excel to do exactly what you're trying to do.
If that doesn't completely solve what you're doing, the extension does pull all the pullable fields from GA. It also gives you an insight into what kind of request it sends to G to pull the data. Very useful for debugging, but also for learning the reporting API.
Alternatively, there's documentation on the API here: https://developers.google.com/analytics/devguides/reporting/core/v4
Make sure you know whether you're using GA4 or GA UA. They have different APIs.

Retrieve Google Analytics 4 event parameters via API

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

How to get a list of available metrics and dimensions for use with the Google analytics API

There are several metrics and dimensions - let it be a list.
For example:
Year dimension and New Session measure.
How to get a list of available metrics and dimensions for this list via Google Analytics API java SDK V3 so that the error does not fall
"Selected dimensions and metrics cannot be queried together"?
Dimensions and metrics list
How to get a list of available metrics and dimensions for this list via Google Analytics API .
The first thing you need to understand is that the Google Analytics Core reporting API and the Google Analytics reporting APIs. Only return the data from within Google analytics. Neither has the power to return to you a list of dimensions and metrics.
To get a list of Dimensions and metrics that can be used in these APIs you should look at the Meta data api . It returns a list of all the dimensions and metrics that can be used with the Google Analytics APIs to query Google analytics data.
Example
GET https://www.googleapis.com/analytics/v3/metadata/ga/columns
Invalid dimension and metric reference.
"Selected dimensions and metrics cannot be queried together"?
Message means that some metrics and dimensions just cant be queried together because there isnt the proper data relation between them. There is no api that will tell you which dimensions and metrics can be queried together.
You have two options:
You can use the Dimensions & Metrics Explorer to check which dimensions and metrics can be used together they will be grayed out if they cant be used together.
You can just make a request as you have and check for an error.
Sulution: take json from here https://ga-dev-tools.appspot.com/ga_cubes.json - this is a list of cubes. For each cube it contains the set of dimensions and metrics that it consists of.
The algorithm is as follows:
We run through the List (for example Year dimension and New Session measure), and look if at least one of these cubes has all the dimensions and metrics from the list, then such metrics and dimensions are compatible, otherwise not.
So it works in https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/
However, it is worth considering that some metrics work together only when there is an additional dimension. For example: ga:14dayUsers, ga:newUsers works only with days dimension.

How to check other available metrics

We are making API call to https://analyticsreporting.googleapis.com/v4/reports:batchGet
Below are the Metrics Data which we are receiving from Google Analytics API. Can someone help me in understanding what all other metrics we have and how to check that?
"ga:transactions"
"ga:sessions"
"ga:transactionRevenue"
"ga:itemQuantity"
"ga:users"
Thanks,
pavan..
The Dimensions & Metrics Explorer lists and describes all of the dimensions and metrics available through the Core Reporting API.
The Dimensions & Metrics Explorer has the following features:
Explore all of the dimensions and metrics – Search or browse by group. Select a dimension or metric for additional details such as descriptions and attributes.
Identify valid combinations – Not all dimensions and metrics can be queried together. Only certain dimensions and metrics can be used together to create valid combinations. Select a dimension or metric checkbox to see all the other values that can be combined in the same query.
https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/

Google Analytics custom dimension and metrics

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

Resources