GetAccountHierarchy.php on Google Ads API

144 views
Skip to first unread message

Didier Roy

unread,
Mar 7, 2019, 5:45:06 AM3/7/19
to AdWords API and Google Ads API Forum
Hi All

I a looking for the equivalent of Google Adwords API GetAccountHierarchy.php on Google Ads API.

thanks


googleadsapi...@google.com

unread,
Mar 7, 2019, 2:53:19 PM3/7/19
to AdWords API and Google Ads API Forum
Hello Didier,

To get the account hierarchy via Google Ads API, you could use the customer_client resource. Through which you can get only the resource name, level, Boolean value of hidden status and Client_customer details of the accounts under your manager account. To get these details the OAuth credentials used to make the API call should be of manager account and the ClientCustomerId passing in the header should be of manager account. Below is the sample query for your reference. 

Please note that, you have to iterate through all the customers to get the descriptive_name. To keep the data normalized we are holding only one resource responsible for a data field. 

Query in PHP format is below:

$query = 'SELECT customer_client.resource_name,
                customer_client.client_customer,
                customer_client.level, customer_client.hidden,
                customer_client.level
                FROM customer_client';

Please let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

cv

unread,
Mar 14, 2019, 8:26:37 AM3/14/19
to AdWords API and Google Ads API Forum
Hello Sai,

To get these details the OAuth credentials used to make the API call should be of manager account and the ClientCustomerId passing in the header should be of manager account.

->Initially we do not have any customerId that could be pass to header. Which service/resource I need to use to get those Accounts?
My question , one user has just authorised my webapp to get the details of the adwords account, how can I know that which account he has given me access for?
I am asking similar service like $CustomerService->getCustomers(); that we used for Adwords API. 
We will then check if that is MCC account or normal account and then follow steps accordingly.


Thanks,

googleadsapi...@google.com

unread,
Mar 14, 2019, 2:37:41 PM3/14/19
to AdWords API and Google Ads API Forum
Hello Chirag,

The equivalent to the $CustomerService->getCustomers(); in new Google Ads API is ListAccessibleCustomers from the CustomerService. Please give it a try and let me know if you have any further questions.


Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

cv

unread,
Mar 15, 2019, 12:49:50 AM3/15/19
to AdWords API and Google Ads API Forum
Hello Sai,

I was trying same example ListAccessibleCustomers.php before posting the question, but end result are different.
I get all accounts under MCC with Adwords API but only MCC account with Ads API.

Thanks,

googleadsapi...@google.com

unread,
Mar 15, 2019, 1:34:28 PM3/15/19
to AdWords API and Google Ads API Forum
Hello Chirag,

The ListAccessibleCustomers API call will result only the accounts that are directly accessible by the user. For example, I attached the screenshot of my test account in which my email address has access to 4 account which can be seen from the top right corner of the AdWords account once you logged in. I am able to pull those 4 accounts using the ListAccessibleCustomers API call. If you still has concerns please share the email address of the user to which the OAuth credentials of the API call belong to. You could use reply privately to the author option while sharing the information requested.


Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
ListAccessibleCUstomers.png
Reply all
Reply to author
Forward
0 new messages