Google Ads API search queries not returning certain data values

76 views
Skip to first unread message

Dylan McBurnett

unread,
Sep 18, 2019, 12:33:18 PM9/18/19
to AdWords API and Google Ads API Forum
Hi,

I'm using the Google Ads API with the Interactive Query Builder along with the google-ads-python Github to search for specific data values. I'm getting about half the data I'm looking for despite using queries provided by the Query Builder .. the queries work for some data values, but not all. Any insight into how to search for the missing data would be much appreciated.

Bid Strategy Type - this field is also not returned when searching 'FROM campaign'

queryStrat = ( 'SELECT bidding_strategy.type, bidding_strategy.name '
'FROM bidding_strategy '
'LIMIT 20')


Terminal Output:
Dylan-McBurnetts-MacBook-Pro:basic_operations dylanmcburnett$ ./get_dylan_data.py -c 4461958680
<google.api_core.page_iterator.GRPCIterator object at 0x110ebc310>
hello
No handlers could be found for logger "google.ads.google_ads.client"
Why are you so wrong?
Request with ID "DHHKl7dGZ-ACUPdvZPrE5g" failed with status "INVALID_ARGUMENT" and includes the following errors:
        Error with message "Error in SELECT clause: invalid field name 'FROM'.".

Code being executed:

from __future__ import absolute_import

import argparse
import six
import sys

import google.ads.google_ads.client


_DEFAULT_PAGE_SIZE = 1000


def main(client, customer_id, page_size):
ga_service = client.get_service('GoogleAdsService', version='v2')

queryStrat = ( 'SELECT bidding_strategy.type, bidding_strategy.name, '
'FROM bidding_strategy '
'LIMIT 20')

results = ga_service.search(customer_id, query=queryStrat, page_size=page_size)
print str(results)
print 'hello'

try:
for row in results:
print '******** ROW DATA'
print str(row)
print('Campaign with ID %d and name/Priority "%s" was found.'
% (row.campaign.id.value, row.campaign.shopping_setting.campaign_priority))
# % (row.campaign.id.value, row.campaign.name.value))
except google.ads.google_ads.errors.GoogleAdsException as ex:
print 'Why are you so wrong?'
print('Request with ID "%s" failed with status "%s" and includes the '
'following errors:' % (ex.request_id, ex.error.code().name))
for error in ex.failure.errors:
print('\tError with message "%s".' % error.message)
if error.location:
for field_path_element in error.location.field_path_elements:
print('\t\tOn field: %s' % field_path_element.field_name)
sys.exit(1)


if __name__ == '__main__':
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
google_ads_client = (google.ads.google_ads.client.GoogleAdsClient
.load_from_storage())
parser = argparse.ArgumentParser(
description='Lists all campaigns for specified customer.')
# The following argument(s) should be provided to run the example.
parser.add_argument('-c', '--customer_id', type=six.text_type,
required=True, help='The Google Ads customer ID.')
args = parser.parse_args()

main(google_ads_client, args.customer_id, _DEFAULT_PAGE_SIZE)


Running a similar query below fails to return any data for:
- bidding_strategy.type
- language_code
- url_custom_parameters
query2 = ( 'SELECT campaign.id, campaign.name, '
'segments.ad_network_type, segments.device, '
'bidding_strategy.type, campaign.dynamic_search_ads_setting.language_code, '
'campaign.shopping_setting.campaign_priority, '
'campaign_budget.type, campaign.url_custom_parameters '
'FROM campaign '
'LIMIT 20')


Other values that I am unable to query:
- 'keyword_plan_negative_keyword'
- 'campaign_criterion.bid_modifier'

Values I have successfully queried:
- segments.ad_network_type
- 'campaign_budget.delivery_method'
- 'segments.device from campaign'
- 'conversion_action.attribution_model_settings.attribution_model'

Google Ads API Forum Advisor Prod

unread,
Sep 19, 2019, 5:00:43 PM9/19/19
to dylan.m...@mightyhive.com, adwor...@googlegroups.com
Hello Dylan, 

Thank you for sharing the details. They were really helpful. I was able to take a look at the logs and replicate the issue. I see that you have a comma before the FROM. Could you please retry the request to see if it's working on your end?

Regards,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UHHEKo:ref

Dylan McBurnett

unread,
Sep 19, 2019, 8:36:48 PM9/19/19
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Sure thing!
I've since fixed the comma and I'm still not getting any data back for my query:
queryNegKey = ( 'SELECT '
     'keyword_plan_negative_keyword.id, keyword_plan_negative_keyword.resource_name '
'FROM keyword_plan_negative_keyword '
'LIMIT 50' )

Just getting an empty object back and I'm not sure why.

Everything else is now working perfectly but I'm still having issues with the negative keywords.
--


DYLAN McBURNETT
Senior Technical Solutions Engineer | MightyHive
P: (512) 920-8543
E: dylan.m...@mightyhive.com

Google Ads API Forum Advisor Prod

unread,
Sep 20, 2019, 12:41:35 PM9/20/19
to dylan.m...@mightyhive.com, adwor...@googlegroups.com
Hi Dylan, 

It looks like you are already in touch with my colleague regarding this concern here. Please continue the discussion on that thread to avoid duplicates.

Thanks,
Reply all
Reply to author
Forward
0 new messages