Now , I could deal with
mapping relationship between country_criterion_id and country name .
But with difficulties in this situation(python code):
import argparse
from itertools import product
import multiprocessing
import time
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.protobuf import json_format
googleads_client = GoogleAdsClient.load_from_storage(version="v10")
ga_service = googleads_client.get_service("GoogleAdsService")
query = """
SELECT
geographic_view.country_criterion_id,
segments.date,
campaign.id,
campaign.name,
customer.currency_code,
customer.descriptive_name,
metrics.clicks,
metrics.cost_micros,
metrics.impressions,
metrics.conversions
FROM
geographic_view
WHERE
segments.date DURING LAST_30_DAYS
"""
# PARAMETERS omit_unselected_resource_names = true , it's just filter the column , but not aggregation data .
customer_id="***"
stream = ga_service.search_stream(
customer_id=customer_id, query=query
)
result_strings = []
for batch in stream:
for row in batch.results:
print(row)
geographic_view=row.geographic_view
campaign = row.campaign
ad_group = row.ad_group
criterion = row.ad_group_criterion
metrics = row.metrics
segments = row.segments
customer = row.customer
result_string=(
f' country_criterion_id : "{geographic_view.country_criterion_id}"'
f' date : "{segments.date}"'
f' id : "{
campaign.id}"'
f' name : "{
campaign.name}"'
f' currency_code : "{customer.currency_code}"'
f' descriptive_name : "{customer.descriptive_name}"'
f' clicks : "{metrics.clicks}"'
f' cost_micros : "{metrics.cost_micros}"'
f' impressions : "{metrics.impressions}"'
f' conversions : "{metrics.conversions}"'
)
result_strings.append(result_string)
Although "geo_target_constant.resource_name" not in select clause , the response data also contain this data dimension .
To what i want , the data aggregation by geo_target_constant.resource_name , eg: each campaign only one row for each geo_country .
Now , my solution is downloading the data and aggregation it by the database , so i wangt know if there is any solution for this situation to economize aggregation response by self ?
response data example:
customer {
resource_name: "customers/****"
descriptive_name: "****"
currency_code: "USD"
}
campaign {
resource_name: "customers/ ******/campaigns/ ******"
name: "
****"
id: *****
}
metrics {
clicks: 479
conversions: 345.0
cost_micros: ******
impressions: 40230
}
segments {
date: "2022-03-28"
}
geographic_view {
resource_name: "customers/
****** /geographicViews/2840~LOCATION_OF_PRESENCE"
country_criterion_id: 2840
} ,
customer {
resource_name: "customers/
****"
descriptive_name: "****"
currency_code: "USD"
}
campaign {
resource_name: "customers/****/campaigns/****"
name: "****"
id:
****
}
metrics {
clicks: 0
conversions: 1.0
cost_micros: ****
impressions: 59
}
segments {
date: "2022-03-28"
}
geographic_view {
resource_name: "customers/
****/geographicViews/2840~AREA_OF_INTEREST"
country_criterion_id: 2840
}
Looking forward to your reply.
Best.