API to get all accounts

168 views
Skip to first unread message

Sibtain Ali

unread,
Jul 22, 2019, 3:35:29 AM7/22/19
to AdWords API and Google Ads API Forum
Hello,

I'm trying to fetch all of the accounts that I have access to via my email through your API. 

When I use the web panel, I see all of the accounts listed perfectly well. 

However, whenever I try the api endpoints, I get different results. For example, ManagedCustomerService shows two accounts ( instead of three ) and CustomerService shows only one account. It seems to work your web panel but not through the API.

Furthermore, Whats the difference between the ManagedCustomerService and CustomerService endpoints?

This has been driving me nuts from quite some time. I must say that the endpoints are not very clearly documented.

Looking forward for your help.

Thanks

Google Ads API Forum Advisor Prod

unread,
Jul 22, 2019, 5:56:17 AM7/22/19
to adwor...@googlegroups.com

Hi Sibtain,

If you are trying to fetch all of the accounts associated to your email address, you may use CustomerService.getCustomers() without specifying a clientCustomerId. This should return up to 5 accounts which your OAuth2 credentials (generated using your email) has direct access. You may also check this blog post for your reference.

With regard to the difference between the ManagedCustomerService and CustomerService, ManagedCustomerService.get() should return all sub accounts with specifying an MCC as the clientCustomerId in the request header (You may refer to this sample). CustomerService will return only the customer information based on the clientCustomerId, or the accounts associated to the OAuth2 credentials.

Please let me know if you have further concern.

Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UEFyCB:ref

James John

unread,
Jul 22, 2019, 6:48:52 AM7/22/19
to AdWords API and Google Ads API Forum
+1 for this. Poorly documented.
How can I CustomerService.getCustomers() in the PHP library, can't seem to find the proper document for information.

Google Ads API Forum Advisor Prod

unread,
Jul 23, 2019, 3:47:15 AM7/23/19
to adwor...@googlegroups.com

Hi James,

I'm sorry for the inconvenience.

Could you confirm if what you are looking for is the sample PHP code for CustomerService.getCustomers()? If yes, unfortunately, we don't have exact code samples for that. With this, I would recommend you to reach out to the PHP client library owner via this link as they may provide the specific sample code that you are looking for.

Please let me know if you have further clarification.



Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UEFyCB:ref

James John

unread,
Jul 24, 2019, 9:29:27 AM7/24/19
to AdWords API and Google Ads API Forum
Now I am very confused which to use. I have been using this library https://github.com/googleads/google-ads-php but now I am seeing this, https://github.com/googleads/googleads-php-lib
Which is the right one?

Google Ads API Forum Advisor Prod

unread,
Jul 24, 2019, 11:57:06 PM7/24/19
to adwor...@googlegroups.com

Hi James,

Could you confirm if what you are using is AdWords API or Google Ads API? The first one (https://github.com/googleads/google-ads-php) is for Google Ads API, and the other one (https://github.com/googleads/googleads-php-lib) is for AdWords API. Please use those client libraries depending on the API you are using.

Let me know if this helps and you may write back if you have any additional concerns.



Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UEFyCB:ref

רועי

unread,
Jul 25, 2019, 3:36:25 AM7/25/19
to AdWords API and Google Ads API Forum
Hi,
When we used CustomerService.getCustomers() a client reported that he got "No Adwords Account Found" or something like that so we changed to ManagedCustomerService.get() And then only one of my accounts was available.
What could be the problem ?

Google Ads API Forum Advisor Prod

unread,
Jul 25, 2019, 5:58:35 AM7/25/19
to adwor...@googlegroups.com

Hi,

Could you confirm if the error you encountered is AuthenticationError.CUSTOMER_NOT_FOUND error? If yes, it means that the account was not found for the customer ID provided in the header. However, to further investigate this, could you provide the complete SOAP request and response logs for both CustomerService.getCustomers() and ManagedCustomerService.get() via Reply privately to author?



Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UEFyCB:ref

Sibtain Ali

unread,
Jul 30, 2019, 1:09:19 PM7/30/19
to AdWords API and Google Ads API Forum
Sure.
Here are the responses:
1) Managed Customer Service

Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerPage Object
(
[entries:protected] => Array
(
[0] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
(
[name:protected] => Ishtiaq Ali
[customerId:protected] => 4471200739
[canManageClients:protected] =>
[currencyCode:protected] => PKR
[dateTimeZone:protected] =>
[testAccount:protected] =>
[accountLabels:protected] =>
[excludeHiddenAccounts:protected] =>
)

[1] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomer Object
(
[name:protected] => כמה-עולה
[customerId:protected] => 1386640593
[canManageClients:protected] =>
[currencyCode:protected] => ILS
[dateTimeZone:protected] =>
[testAccount:protected] =>
[accountLabels:protected] =>
[excludeHiddenAccounts:protected] =>
)

)

[links:protected] => Array
(
[0] => Google\AdsApi\AdWords\v201809\mcm\ManagedCustomerLink Object
(
[managerCustomerId:protected] => 4471200739
[clientCustomerId:protected] => 1386640593
[linkStatus:protected] =>
[pendingDescriptiveName:protected] =>
[isHidden:protected] =>
)

)

[totalNumEntries:protected] => 2
[PageType:protected] => ManagedCustomerPage
[parameterMap:Google\AdsApi\AdWords\v201809\cm\Page:private] => Array
(
[Page.Type] => PageType
)

)

2) Customer Service

Array ( [0] => Google\AdsApi\AdWords\v201809\mcm\Customer Object ( [customerId:protected] => 7925160432 [currencyCode:protected] => USD [dateTimeZone:protected] => America/Denver [descriptiveName:protected] => [canManageClients:protected] => [testAccount:protected] => [autoTaggingEnabled:protected] => 1 [trackingUrlTemplate:protected] => [finalUrlSuffix:protected] => [parallelTrackingEnabled:protected] => 1 [conversionTrackingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\ConversionTrackingSettings Object ( [effectiveConversionTrackingId:protected] => 0 [usesCrossAccountConversionTracking:protected] => ) [remarketingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\RemarketingSettings Object ( [snippet:protected] => [googleGlobalSiteTag:protected] => ) ) [1] => Google\AdsApi\AdWords\v201809\mcm\Customer Object ( [customerId:protected] => 4118040730 [currencyCode:protected] => ILS [dateTimeZone:protected] => Asia/Jerusalem [descriptiveName:protected] => פורטל ביטוח [canManageClients:protected] => [testAccount:protected] => [autoTaggingEnabled:protected] => 1 [trackingUrlTemplate:protected] => [finalUrlSuffix:protected] => [parallelTrackingEnabled:protected] => 1 [conversionTrackingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\ConversionTrackingSettings Object ( [effectiveConversionTrackingId:protected] => 989050890 [usesCrossAccountConversionTracking:protected] => ) [remarketingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\RemarketingSettings Object ( [snippet:protected] => [googleGlobalSiteTag:protected] => ) ) [2] => Google\AdsApi\AdWords\v201809\mcm\Customer Object ( [customerId:protected] => 4471200739 [currencyCode:protected] => PKR [dateTimeZone:protected] => Asia/Karachi [descriptiveName:protected] => Ishtiaq Ali [canManageClients:protected] => 1 [testAccount:protected] => [autoTaggingEnabled:protected] => [trackingUrlTemplate:protected] => [finalUrlSuffix:protected] => [parallelTrackingEnabled:protected] => 1 [conversionTrackingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\ConversionTrackingSettings Object ( [effectiveConversionTrackingId:protected] => 0 [usesCrossAccountConversionTracking:protected] => ) [remarketingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\RemarketingSettings Object ( [snippet:protected] => [googleGlobalSiteTag:protected] => ) ) [3] => Google\AdsApi\AdWords\v201809\mcm\Customer Object ( [customerId:protected] => 8238555682 [currencyCode:protected] => USD [dateTimeZone:protected] => America/New_York [descriptiveName:protected] => Pest Control [canManageClients:protected] => [testAccount:protected] => [autoTaggingEnabled:protected] => [trackingUrlTemplate:protected] => [finalUrlSuffix:protected] => [parallelTrackingEnabled:protected] => 1 [conversionTrackingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\ConversionTrackingSettings Object ( [effectiveConversionTrackingId:protected] => 878883669 [usesCrossAccountConversionTracking:protected] => ) [remarketingSettings:protected] => Google\AdsApi\AdWords\v201809\mcm\RemarketingSettings Object ( [snippet:protected] => [googleGlobalSiteTag:protected] => ) ) )

Google Ads API Forum Advisor Prod

unread,
Jul 31, 2019, 12:43:25 AM7/31/19
to adwor...@googlegroups.com

Hi Sibtain,

Thank you for providing the responses and I'm sorry for the confusion.

Upon checking the ManagedCustomerService is working correctly as the client account (138-664-0593) is indeed the only account associated under the MCC account (447-120-0739), and the service returned the account correctly.

With regard to Customer Service, I couldn't see the error in the log you provided. With this, so I can further investigate the issue, could you provide the complete SOAP request and response logs via Reply privately to author? If you haven't enabled logging, please check the logging guide in the respective client library for steps to enable logging.



Regards,
Hiroyuki
Google Ads API Team



ref:_00D1U1174p._5001UEFyCB:ref

Sibtain Ali

unread,
Aug 11, 2019, 12:48:27 PM8/11/19
to AdWords API and Google Ads API Forum
My question was that why are the two endpoints showing different responses? How can I get ALL accounts linked to a particular account?

Google Ads API Forum Advisor Prod

unread,
Aug 12, 2019, 8:49:20 AM8/12/19
to allroun...@gmail.com, adwor...@googlegroups.com
Hello Sibtain, 

Thank you for reaching out to support. I'm Hiro's colleague addressing your concern as he is out of office. Based on the on-going discussion on this thread, I see that you are using two different API services and hence you will be two different endpoints. The ManagedCustomerService.get() returns the list of accounts that meet the selector criteria. The CustomerService.getCustomers() returns details of all the customers directly accessible by the user authenticating the call. 

If you are looking to get the complete account hierarchy, you may use the GetAccountHierarchy code sample in Java as a reference. Code samples in other languages can be found here.

Thanks,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UEFyCB:ref
Reply all
Reply to author
Forward
0 new messages