Posts tagged with google-ads-api

I want to add new columns to the Account Summary Report: https://developers.google.com/google-ads/scripts/docs/solutions/account-summary

But I'm getting an error.

'report_fields': [ {'columnName': 'metrics.cost_micros', 'displayName': 'Cost'}, {'columnName': 'metrics.average_cpc', 'displayName': 'Avg. CPC'}, {'columnName': 'metrics.ctr', 'displayName': 'CTR'}, {'columnName': 'metrics.search_impression_share', 'displayName': 'Search Impr. share'}, {'columnName': 'metrics.impressions', 'displayName': 'Impressions'}, {'columnName': 'metrics.clicks', 'displayName': 'Clicks'}, {'columnName': 'metrics.conversions', 'displayName': 'Conversions'}, {'columnName': 'metrics.conversions_value', 'displayName': 'Revenue'}, {'columnName': 'metrics.cost_per_conversion', 'displayName': 'CPA'}, {'columnName': 'metrics.conversions_from_interactions_rate', 'displayName': 'CVR'} 

--- Error---

Error: Unknown field metrics.conversions     at format (Code:174:13)     at Code:97:33     at Array.map (<anonymous>)     at main (Code:96:55) 

I am trying to list all sub accounts in a manager account. I am using the listAccessibleCustomers method in the example below but it is only returning the main customer accounts and not the sub/linked accounts even though I have access to the sub accounts, because I can successfully request a campaign list of one of the sub accounts.

Here is the code I use that's only returning the main accounts.

$this->auth(); $customerServiceClient = $this->$googleAdsClient->getCustomerServiceClient(); // Issues a request for listing all accessible customers. $accessibleCustomers = $customerServiceClient->listAccessibleCustomers(); // Iterates over all accessible customers' resource names. $allitems = array(); foreach ($accessibleCustomers->getResourceNames() as $resourceName) {     /** @var string $resourceName */     array_push($allitems,array("name"=>$resourceName)); } return array("count"=>count($accessibleCustomers->getResourceNames()),"items"=>$allitems); 

Here is the response:

array(2) {      ["count"]=> int(2)      ["items"]=> array(2) {          [0]=> array(1) { ["name"]=> string(20) "customers/**********" }          [1]=> array(1) { ["name"]=> string(20) "customers/**********" }      }  } 

Ultimately it needs to return all the sub/linked accounts of the account that's specified as the loginCustomerId inside the google_ads_php.ini file. Any help would be appreciated.

With the "Google Ads API" - PHP Client Library.

While calling the "GetCampaigns.php" / "ListAccessibleCustomers.php" example code. I was still getting this error (below) but found a solution (check answer).

Error -

authorization_error: User doesn't have permission to access customer.  Note: If you're accessing a client customer,  the manager's customer id must be set in the 'login-customer-id' header.  See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid