GAQL: Filter CustomerClients by Impressions

38 views
Skip to first unread message

Michael Ladewig

unread,
Apr 9, 2019, 5:26:44 AM4/9/19
to AdWords API and Google Ads API Forum
Hi guys,

we are an agency and under our agency-account, there are a lot of CustomerClients. our API Scripts have to iterate over these Accounts. To only address active used accounts we want to Filter CustomerClients by their Impression during the last 30 days. So I tried to use a GAQL query to get a list of Account-IDs with at least 1 Impression during the last 30 days:

query = ('SELECT customer_client.client_customer, customer_client.resource_name, metrics.impressions FROM customer_client WHERE segments.date DURING LAST_30_DAYS AND metrics.impressions > 0')


Unfortunately, it seems, that customer_client is not able to work with metrics.impressions. The Script returns:

Request made: ClientCustomerId: 5896XXXXXX, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v1.services.GoogleAdsService/Search, RequestId: FXimew-dKfaGgBFv_BfUgQ, IsFault: True, FaultMessage: Cannot select or filter on the following metrics: 'impressions'(could not support requested resources: 'CUSTOMER_CLIENT', 'CUSTOMER_CLIENT'), since metric is incompatible with the resource in the FROM clause or other selected segmenting resources.


 Fetching a List with all CustmerClients and than iterating over each of them manually, seems to work, as a request on Customer can handle metrics.impressions. But i think, this is much more time consuming and not a best practice.

So my question is, if i made any mistake, requesting the CustomerClients or if there is really no Feature of filtering by Metrics.

googleadsapi...@google.com

unread,
Apr 9, 2019, 2:24:36 PM4/9/19
to lad...@exito.de, AdWords API and Google Ads API Forum
Hello Michael, 

Your approach is correct. The customer_client resource does not support any metrics. You will need to use the customer to check if the impressions are available. I have passed on the feedback you have shared with the team. Please keep an eye on our blog for any future updates.

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Michael Ladewig

unread,
Apr 10, 2019, 10:26:32 AM4/10/19
to AdWords API and Google Ads API Forum
Hello Bharani,

thank you for your feedback. So I fetched a list with all the accounts in my main account an tried to get metrics for all of them. Unfortunately, I get an error, if the requestet customer is a Manager. 



def getListOfActiveAccounts(self, allAccounts, metric="Impressions", limit=0):
    __columns
= ['Account ID', 'Account Name']
    dfActiveAccounts
= pd.DataFrame(columns=__columns)
   
for __accountID in allAccounts:
       
print(__accountID)
       
try:
            query
= ('SELECT customer.descriptive_name, customer.manager, metrics.impressions, metrics.clicks FROM customer WHERE customer.manager = False AND segments.date DURING LAST_30_DAYS')
            __customerData
= self.__customer_service.search(__accountID, query=query, page_size=1000)
           
for row in __customerData:
               
print(row.customer.descriptive_name.value + "  --  Impressions: " + str(row.metrics.impressions.value) + "  --  Clicks:" + str(row.metrics.clicks.value) + "  --  Manager: " + str(row.customer.manager.value))
       
except:
           
pass

So I tried to filter customer by customer.manager = False. But this seems to be too late, as the request is already sent with metrics-request and produces an error. For me, it is ok now, because I can fetch the error an pass this customer. I just need Account that have metrics.

But maybee it is a nice additional feedback for your product-team. So maybee it would be possible to filter manager-accounts in customer-resource or in customer_client-resource.

Thanks
Michael
Reply all
Reply to author
Forward
0 new messages