Get ad groups for each accessible costumer account

111 views
Skip to first unread message

André Pimpão

unread,
Aug 19, 2019, 6:09:52 AM8/19/19
to AdWords API and Google Ads API Forum

Hey, there.

I would like to know if someone can help me with this, since I've been struggling here.

I'm trying to get all ad groups for each accessible customer (customers:listAccessibleCustomers) of the authenticated user and respective accounts (I'm trying with customer_clients and there can be multiple levels).
I'm using queries to achieve that, but I'm getting stuck when I'm trying to get the ad groups (after getting the customer clients ids), as I'm really confused which value I should use for the "login-customer-id" header.

Can someone clearly explain what "login-customer-id" should be used to get the ad groups of an account?
Or how to get the manager customer id (for multiple accounts), since it seems that is the id I should be using?

I'm using the new Google Ads API Beta v2.

Thanks in advance.

Google Ads API Forum Advisor Prod

unread,
Aug 19, 2019, 1:57:33 PM8/19/19
to pimpao...@gmail.com, adwor...@googlegroups.com
Hello André, 

If you are using OAuth credentials from a manager account and are accessing a related customer account the login-customer-id header to the customer ID of the manager account. If you are using OAuth credentials from a manager account, then you should be able to find this by logging into your Google Ads manager account on the top right corner. To pull the specific ad group details in a client account, you will need to use the client customer Id here and then pull the specific ad groups from the account. 

Let me know if you have any concerns. 

Thanks,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UEJTua:ref

André Pimpão

unread,
Aug 20, 2019, 6:15:30 AM8/20/19
to AdWords API and Google Ads API Forum
Thanks, Bharani.

In the meantime I started to figure things out.

Part of what was confusing me is that when I query all customer_client for each accessible customer, I get many more accounts that I have access to (or at least that show on my Google Ads panel). For example, one of the accounts in the Google Ads panel lists 31 accounts, but if I query the API it lists 195 accounts, but I only have access to those 31 metioned before, so I get a lot of the following error:

{
   
"error": {
       
"code": 403,
       
"message": "The caller does not have permission",
       
"status": "PERMISSION_DENIED",
       
"details": [
           
{
               
"@type": "type.googleapis.com/google.ads.googleads.v2.errors.GoogleAdsFailure",
               
"errors": [
                   
{
                       
"errorCode": {
                           
"authorizationError": "CUSTOMER_NOT_ENABLED"
                       
},
                       
"message": "The customer can't be used because it isn't enabled."
                   
}
               
]
           
}
       
]
   
}
}

Is there a way to get all customer_client but filtered by enabled?

Thanks,
AP.

Google Ads API Forum Advisor Prod

unread,
Aug 20, 2019, 1:15:12 PM8/20/19
to pimpao...@gmail.com, adwor...@googlegroups.com
Hi André, 

That's right, the customer_client resource will return the complete hierarchy of all the direct and indirect client customers that are included. I'm afraid, it is possible to filter the accounts based on the status. The error CUSTOMER_NOT_ENABLED usually occurs if the API call is made against an account which is not completely setup. Could you please complete the account setup and retry the API request? If you're encountering any issues, could you please share the request and response logs using Reply privately to author option to investigate further?

André Pimpão

unread,
Aug 21, 2019, 10:04:04 AM8/21/19
to AdWords API and Google Ads API Forum
Hi, Bharani.

What seems to be happening is that it is listing accounts that are cancelled.
Ideally, there should be a field with the status of the account, if not to filter directly in the query, at least to know how to handle the different account statuses.

Right now, forcing to loop through every customer_client/account, no matter the status, and "blindly" requesting ad groups for each one is really time consuming and unnecessary.

Is there any plan for this to be available?
Is there any other way?

Thanks once again,
AP.

Google Ads API Forum Advisor Prod

unread,
Aug 21, 2019, 3:47:40 PM8/21/19
to pimpao...@gmail.com, adwor...@googlegroups.com
Hi André, 

Appreciate your feedback. Currently, we do not have a workaround to pull the cancelled accounts. There is already a feature request for this and our team is looking into it. Please keep an eye on our blog for more updates. 

André Pimpão

unread,
Aug 22, 2019, 6:01:27 AM8/22/19
to AdWords API and Google Ads API Forum
Hi, Bharani.

I'll keep an eye on it then.

Thanks for the help,
AP.
Reply all
Reply to author
Forward
0 new messages