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.

Tag:google-ads-api, php

2 comments.

  1. dorian

    The listAccessibleCustomers() method only lists those Google Ads accounts that the calling Google account has direct access to, as you already found out.

    In order to retrieve all of the sub accounts that the uses can access via manager accounts, you'll need to use the customer_client resource.

    There is an example in the Google Ads API PHP client library repository that does pretty much what you want.

    1. Shaun Scholtz

      Thanks I found the example, I thought as much that I needed to use the searchStream queries. Thanks again

Add a new comment.