Is there any campaign report that provide both Geo and campaign data at the same time?

349 views
Skip to first unread message

MJOLNIR TTT

unread,
Apr 21, 2022, 4:36:22 AM4/21/22
to Google Ads API and AdWords API Forum
I've checked geographic_view,
 
query = """
SELECT
        geographic_view.country_criterion_id,
        segments.device,
        segments.date,
        segments.geo_target_county,
        campaign.id,
        campaign.name,
        customer.currency_code,
        customer.descriptive_name,
        metrics.clicks,
        metrics.cost_micros,
        metrics.impressions,
        metrics.conversions,
        metrics.conversions_value,
        metrics.all_conversions,
        metrics.all_conversions_value,
        metrics.interactions
FROM
    geographic_view
WHERE
    segments.date DURING LAST_30_DAYS
ORDER BY metrics.cost_micros DESC
LIMIT 10
 """

This query return nothing , may be cause by segments.geo_target_county,  if delete it , query success .
but , I need both geo info and campaign info at the same time .

result may likes :
country_criterion_id : "2392"
device : "2"
date : "2022-04-06"
id : "16497628522"
geo_target_county: "Japan"
name : "***"
currency_code : "USD"
descriptive_name : "***"
clicks : "557"
cost_micros : "***"
impressions : ""***""
conversions : ""***".0"
all_conversions : ""***".0"
all_conversions_value : ""***".869012458"
interactions : ""***""

Looking forward to your reply.

Best.

Google Ads API Forum Advisor

unread,
Apr 22, 2022, 1:25:34 AM4/22/22
to 110ss...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out.

Since you mentioned that "may be cause by segments.geo_target_county,  if delete it , query success", this appears to be captured by the behavior discussed here, when segments fields are used in this API's reporting feature.

That said, if there are no records that can be associated to the said segments.geo_target_county field, then the report will not have any records to return.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


ref:_00D1U1174p._5004Q2a5OjV:ref

MJOLNIR TTT

unread,
Apr 22, 2022, 3:17:10 AM4/22/22
to Google Ads API and AdWords API Forum
My fundamental needs : campaign report that provide both Geo and campaign data (id, name , cost ). 
But if  geo_target_county is not available in  geographic_view  , which report can use  ? 
is there mapping relationship between country_criterion_id and country name ? 

Google Ads API Forum Advisor

unread,
Apr 24, 2022, 10:20:21 PM4/24/22
to 110ss...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for your reply.

You can still use the geographic_view 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 report as well.

MJOLNIR TTT

unread,
Apr 26, 2022, 9:50:46 AM4/26/22
to Google Ads API and AdWords API Forum
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.

MJOLNIR TTT

unread,
Apr 27, 2022, 12:55:50 AM4/27/22
to Google Ads API and AdWords API Forum
geo_target_constant.resource_name ->  geographic_view. resource_name

Google Ads API Forum Advisor

unread,
Apr 27, 2022, 3:35:13 PM4/27/22
to 110ss...@gmail.com, adwor...@googlegroups.com
Hello,

Can you please clarify what the specific issue is with performing the following:
  1. obtain geo_target segment and campaign data via the geographic_view
  2. associate the geo_target segment resource name with other desired attributes (e.g. "name") with the geo_target_constant report
There isn't a single report that can obtain campaign data, geographic metrics, geo_target attributes (except for resource name).

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 
 

ref:_00D1U1174p._5004Q2a5OjV:ref

MJOLNIR TTT

unread,
Apr 27, 2022, 11:37:19 PM4/27/22
to Google Ads API and AdWords API Forum
ok , The query is : 
"""
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
 """
To my expectation , the response data only contain desired attributes which in select clause .  but it return undesired attributes geographic_view.resource_name that not in select clause ,  and split response into multi rows with different resource_name.  So , i have to aggregate response data by other way . 
I want to make sure if the query post here just return the geographic_view.resource_name attributes even it's not in select clause . 

Google Ads API Forum Advisor

unread,
Apr 29, 2022, 1:29:58 AM4/29/22
to 110ss...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for the reply.

You may use omit_unselected_resource_names and  refer to this documentation for you to not include the resource name of the report you are using.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2a5OjV:ref

Rahul Kumar

unread,
May 6, 2022, 3:00:32 PM5/6/22
to Google Ads API and AdWords API Forum
Hey Guys any update on this. can we pull geo and campaign information now.

Google Ads API Forum Advisor

unread,
May 10, 2022, 4:05:13 AM5/10/22
to rahul...@simplilearn.net, adwor...@googlegroups.com

Hi Rahul,
 

Thanks for your response. I am also a member of the Google Ads API team and let me provide support to your concern.
 

Moving forward to your concern, Could you confirm if you used the provided documentation from my colleague Heidi?
 

Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2a5OjV:ref
Message has been deleted

Google Ads API Forum Advisor

unread,
May 16, 2022, 5:10:56 PM5/16/22
to 110ss...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Could you please provide more details on this issue, so that i can further investigate the issue? If you are getting an error, could you please provide the complete request and response logs, with the request-id?

If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.

Thanks,
Google Logo
Nirmita
Google Ads API Team
 


ref:_00D1U1174p._5004Q2a5OjV:ref

Google Ads API Forum Advisor

unread,
May 16, 2022, 5:11:40 PM5/16/22
to 110ss...@gmail.com, adwor...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads API support team.

Could you please provide more details on this issue, so that i can further investigate the issue? If you are getting an error, could you please provide the complete request and response logs, with the request-id?

If you haven't yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link. You can provide it via Reply privately to author option.  If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.
Reply all
Reply to author
Forward
0 new messages