Tony-Marketing-API.cn is a vibrant community dedicated to Facebook, Meta,Google Ads api, app development, Instagram, and related technologies. It offers valuable bug solutions, troubleshooting cases, and problem-solving strategies shared by users. Stay updated with real-world solutions, development tips, and the latest trends in digital marketing and app development.
for all you guys want to overcome this issue. Google ads api provide api for get list of geo target I'm using python, so this is the piece of codes:
def get_geo_targets(self, customer_id): """ get_geo_targets: return geo list targets Args: customer_id: Returns: """ query_str = """ SELECT geo_target_constant.id, geo_target_constant.name, geo_target_constant.resource_name, geo_target_constant.country_code, geo_target_constant.canonical_name, geo_target_constant.status, geo_target_constant.target_type, geo_target_constant.parent_geo_target FROM geo_target_constant where geo_target_constant.status !='REMOVAL_PLANNED' """ ga_service = self._client.get_service("GoogleAdsService") search_request = self._client.get_type("SearchGoogleAdsStreamRequest") search_request.customer_id = customer_id search_request.query = query_str stream = ga_service.search_stream(search_request) result = [] for batch in stream: for row in batch.results: geo_target_constant = row.geo_target_constant it = { 'resource_name': geo_target_constant.resource_name, 'id': geo_target_constant.id, 'name': geo_target_constant.name, 'country_code': geo_target_constant.country_code, 'target_type': geo_target_constant.target_type, 'status': geo_target_constant.status, # 'countrY_name': process_country(row.canonical_name), 'canonical_name': geo_target_constant.canonical_name, 'parent_geo_target': geo_target_constant.parent_geo_target} result.append(it) return resultthe resource_name return from api, is the segments.geo_target_region return from geographic_view, just mapped it.