To whom it may concern,
*What is the issue in my code or is there a way to extend the
deadline/timeout?*
I am trying to run a user location report by clicks,cost for Country:USA by
states for 1 week.
When I try to run a geographic view reports for clicks, cost by region by 1
week with the following code I receive a *deadline 504 error*, but I run
the same code for no regions and 1 day it works in 2 seconds.
See attached python scripts and code below for reference.
'''SELECT
segments.geo_target_region,
metrics.clicks,
metrics.cost_micros
FROM
geographic_view
WHERE
customer.id = XXXXXXXXXXX
AND geographic_view.country_geo_target_constant =
'geoTargetConstants/2840'
AND geographic_view.location_type = 'LOCATION_OF_PRESENCE'
AND segments.week = '2019-04-15'
ORDER BY metrics.clicks DESC
LIMIT
100'''
Even when I try to run the attached code for a week, I still receive a *504
deadline error*.
'''SELECT
metrics.clicks,
metrics.cost_micros
FROM
geographic_view
WHERE
customer.id = XXXXXXXXXX
AND geographic_view.country_geo_target_constant =
'geoTargetConstants/2840'
AND geographic_view.location_type = 'LOCATION_OF_PRESENCE'
AND segments.week = '2019-04-15'
ORDER BY metrics.clicks DESC
LIMIT
100'''
But I can run the following code without issue and it takes 2 seconds.
'''SELECT
metrics.clicks,
metrics.cost_micros
FROM
geographic_view
WHERE
customer.id = XXXXX
AND geographic_view.country_geo_target_constant =
'geoTargetConstants/2840'
AND geographic_view.location_type = 'LOCATION_OF_PRESENCE'
AND segments.date = '2019-04-15'
ORDER BY metrics.clicks DESC
LIMIT
100'''
*python package version*: google-ads 1.3.1
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/08697597-a5b9-40e0-8df5-78a6e56a02b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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='v1')
query = ('''SELECT
segments.geo_target_region,
metrics.clicks,
metrics.cost_micros
FROM
geographic_view
WHERE
customer.id = XXXXXXXXX
AND geographic_view.country_geo_target_constant = 'geoTargetConstants/2840'
AND geographic_view.location_type = 'LOCATION_OF_PRESENCE'
AND segments.week = '2019-04-15'
ORDER BY metrics.clicks DESC
LIMIT
1000''')
response = ga_service.search(customer_id, query, page_size=page_size)
for row in response:
print(row)
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=('Retrieves us states, clicks, '))
# 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)