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.
在2022年4月25日星期一 UTC+8 10:20:21<adsapi> 写道:

> Hi,
>
> Thank you for your reply.
>
> You can still use the geographic_view 
> <https://developers.google.com/google-ads/api/fields/v10/geographic_view?hl=en>
>  
> to retrieve records based on "*metrics aggregated at the country level, 
> one row per country*", and then associate those to a campaign. However, 
> these metrics may not always be associated to specific segments fields.
>
> If you then wish to retrieve more details regarding the geographic 
> location returned in the geographic_view report, and also for your concern 
> "*is 
> there mapping relationship between country_criterion_id and country name ?*", 
> you can perform a separate request using the geo_target_constant 
> <https://developers.google.com/google-ads/api/fields/v10/geo_target_constant?hl=en>
>  
> report as well.
>
>
> Best regards,
>
> [image: Google Logo] 
> Peter Laurence 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2a5OjV:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/4d177b46-b192-4148-8de3-763541ede0ecn%40googlegroups.com.
  • Is... MJOLNIR TTT
    • ... MJOLNIR TTT
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... MJOLNIR TTT
          • ... MJOLNIR TTT
            • ... MJOLNIR TTT
              • ... Rahul Kumar
                • ... MJOLNIR TTT

Reply via email to