Google Analytics - Query all the metrics and dimensions names [duplicate] - google-analytics

I am trying to use Google Analytics API, need to get metrics and dimensions list through Google Analytics API.
How to get metrics and dimensions list using Google Analytics API functions in php?

This is not available through the API.
the full list of dimensions and metrics is available at the developer.google.com/analytics site:
https://developers.google.com/analytics/devguides/reporting/core/dimsmets
UPDATE 2016-03-26
Since this answer was posted there were some developments in this area and now this is available in an api. I can't delete this answer since it's accepted check the response from #augustin
The Google Analytics Metadata API The Metadata API returns the list and attributes of columns (i.e. dimensions and metrics) exposed in the Google Analytics reporting APIs. Attributes returned include UI name, description, segments support, and more. At this time the response is only metadata for the Google Analytics Core reporting API V3 and the Google Analytics Reporting API v4. Real-time and MCF metadata is not available.

If you need the list of dimensions and metrics you can use analytics.metadata.columns.list functionality from Google Analytics API v3.
You can make a CURL request with PHP like:
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://www.googleapis.com/analytics/v3/metadata/ga/columns?key={YOUR_API_KEY}',
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
https://developers.google.com/analytics/devguides/reporting/metadata/v3/reference/metadata/columns/list?hl=en

Related

Custom Event Track Google Tag Manager using REST API

I want to add Track an analytics custom event to my nodejs file. Is there any ways to do using REST api.
The Equivalent of this using REST API:
analytics.track('customEvent', {
label: 'lorem',
price: 20
})
You can use the Google Analytics Measurement Protocol that allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers: https://developers.google.com/analytics/devguides/collection/protocol/v1

No Google Analytics History available for some client IDs

I use the GoogleAnalyticsR R library for calling the Google Analytics API to extract the client history for some Google Analytics clientID. This seems however like a general problem with either the API or how Google Analytics saves the Web History data of Visitors.
For some ga clids I get no history but an error instead:
ga_clientid_activity(ids="1919844353.15xxxxxxxx" , viewId =138xxxxx, id_type = "CLIENT_ID")
Output:
Request Status Code: 400
Why is the Visitor History missing or not extractable via the API?

Analytics Reporting API v4 "viewId must be set" issue

We are using Analytics Reporting API v4 in our backend to process analytical data collected from our clients (apps & website). We are facing an issue that the reporting API requires a viewId parameter to be present in the request that queries analytical data, otherwise the request fails.
// create the ReportRequest object
ReportRequest request = new ReportRequest().setViewId("your-view-id-here")
.setDateRanges(Arrays.asList(dateRange))
.setDimensions(Arrays.asList(browser))
.setMetrics(Arrays.asList(sessions));
According to their documentation, the viewId parameter can be extracted from the Google Analytics Console, which is correct.
The problem we are facing is that our "Website" property in Google Analytics already has a view where we can extract the ID from under it's settings:
This is great and exactly what we need, but for the "iOS" and "Android" properties, there is no view and the button to create one is greyed out:
Is there any way to query the API without specifying a viewId or is there a way to create a view in the console that we are unaware of?
Could the issue be caused by the fact that we are using Firebase to collect our data in Android and iOS?

can I access the unique client Id through GA API?

I am currently querying my Google Analytics data using the Google Analytics API via R.
I would like to query based on the unique client ID as my primary dimension, but I can't find this dimension using the API.
Is it possible to query Google analytics from the API using the client Id as a dimensions?
Update: Client ID is now available in Google Analytics Core Reporting api as ga:clientId.
I've added it in my script and works seamlessly.
Query explorer doesn't support it yet, hopefully soon...
The only dimensions and metrics that you can use with the Google Analytics API can be found in the Dimensions and metrics explorer you could also check the metadata API.
As you can see client id is not a valid dimension exposed via the Google Analytics API. You could set this in a custom dimension yourself however for it to work your going to have to make sure that its set on every single request you send to Google Analytics.
then you can use the custom dimension metadata
update
As of late 2018 early 2019 it is now possible to query ga:clientid from the google analytics api.

Google Maps V3 API: How can I get report of the use of the DIRECTIONS and GEOCODE APIS

I am using Google Maps API v3 in a Web.
And also I am using:
new google.maps.Geocoder(); (GEOCODING)
new google.maps.DirectionsService(); (DIRECTIONS for trace routes between 2 places)
Then I went to API Developers Console and create a KEY and I call the Google service in this way usin the key:
http://maps.google.es/maps/api/js?key='the-key-from-api-console'&sensor=true
The intent of this is to keep track of the use of apis to watch that I do not pass the limits of use.
In the API console Google reports me ok about the use of the javascript API v3 counting the number of visits, the number of loads of the maps even the URL of the pages that use the maps.
I can see that my use of this service does not exceed 25,000 requests / day
But i need reports of the use of GEOCODING and DIRECTIONS too and Google is not reporting me this info. In developers console I activated the Directions API, the Geocoding API and Google Maps JavaScript API v3. But I only get reports of Maps JavaScript API v3.
Report of Directions API and the Geocoding API stay always at 0%. It is as if Google is not using this report.
Could it be that the service should be contracted to have this data or to be other types of APIS enable the console in order to have use of this report?
I've been trying to find information clarifying this for me but I found nothing that completely solved my doubt.
Thanks in advance.
When you use both services via the methods of the Javascript-API the limits apply to the user that visits the page with the map, the quota of your account is not affected(so there is nothing to count/report for your account/project)
It applies to your account only when you request the webservices(usually via serverside scripts).

Resources