Hello, I am tried to clone date range geographic view report by python
But when I want to segments city, county, (province, canton, state) at the
same time, It will return an empty file.I can only segment by city and
county.
Is there a way to query city county sate level at the same time? And also
showing the name of the city, the name of the sate. not the id.
thanks
sample code is below:
ga_service = client.get_service("GoogleAdsService")
# GAQL query create
query = """
SELECT segments.geo_target_city,
geographic_view.country_criterion_id,
segments.geo_target_region,
metrics.impressions,
campaign.name,
campaign.id,
ad_group.name,
metrics.clicks,
metrics.cost_micros,
metrics.conversions,
metrics.conversions_value
FROM geographic_view
WHERE segments.date BETWEEN '""" + start_date + """' AND '""" +
end_date + """'
"""
# name of the city (not id)
# create empty data frame
# igonre metro as this time
column_names = ['City',
'Country/Territory',
'segments.geo_target_region',
'Impressions',
'Campaign',
'Campaign ID',
'Ad group',
'Clicks',
'Cost',
'Conversions',
'Total conv. value']
df = pd.DataFrame(columns = column_names)
# Issues a search request using streaming.
search_request = client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = customer_id
search_request.query = query
stream = ga_service.search_stream(search_request)
query_lists = []
for batch in stream:
#print(batch)
for row in batch.results:
geographic_view = row.geographic_view
segments = row.segments
campaign = row.campaign
metrics = row.metrics
ad_group = row.ad_group
query_list = [segments.geo_target_city,
geographic_view.country_criterion_id,
segments.geo_target_region,
segments.geo_target_canton,
metrics.impressions,
campaign.name,
campaign.id,
ad_group.name,
metrics.clicks,
metrics.cost_micros,
metrics.conversions,
metrics.conversions_value]
query_lists.append(query_list)
df = pd.DataFrame(np.array(query_lists), columns=column_names)
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/372c7e33-4e2f-434e-b388-86b3114d399cn%40googlegroups.com.