Goog day. When I try to get custom dimensions via API, I got error
Exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/customDimensions: (400) Cannot query by ~all for id webPropertyId'
My code
$service_account_name = '<Service Email>@developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_customDimensions->listManagementCustomDimensions('~all', '~all');
print_r($result);
Similar code for getting goals works correctly
$service_account_name = '<Service Email>@developer.gserviceaccount.com';
$key_file_location = '<keyName>.p12';
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(Google_Service_Analytics::ANALYTICS),
$key,
'notasecret',
'http://oauth.net/grant_type/jwt/1.0/bearer',
'<My email>'
);
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->management_profiles->listManagementProfiles('~all', '~all');
print_r($result);
Both methods listManagementProfiles and listManagementProfiles get parametrs $accountId and $webPropertyId . Could someone help, why I get error, while getting custom dimensions via API?
listManagementProfiles
with the~all
parameter, If you want a list of All accounts, properties and views you should call the Account Summaries endpoint. – Matt