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?
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
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