En esta guía, se proporciona un conjunto de consultas del lenguaje de consulta de Google Ads que demuestran cómo mostrar los mismos datos que las pantallas en la IU de Google Ads y cómo las constantes geográficas. Puedes usar estas consultas tal como están o como puntos de partida en para crear tus propias consultas personalizadas.
Cómo replicar las pantallas de la IU de Google Ads
En esta sección, se muestran las consultas a la API que muestran los mismos datos que la configuración predeterminada pantallas de la IU de Google Ads. Si estás creando una app muestra métricas y datos al igual que en Google Ads, estas consultas pueden ayudarte datos análogos de la API.
Campañas
La pantalla Descripción general de las campañas predeterminadas en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.optimization_score, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.optimization_score, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED' " }'
Grupos de anuncios
La pantalla de resumen predeterminada de los grupos de anuncios en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group.name, campaign.name, ad_group.status, ad_group.type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM ad_group WHERE segments.date DURING LAST_7_DAYS AND ad_group.status != 'REMOVED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group.name, campaign.name, ad_group.status, ad_group.type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM ad_group WHERE segments.date DURING LAST_7_DAYS AND ad_group.status != 'REMOVED' " }'
Anuncios
La pantalla Resumen de Google Ads predeterminada en la IU.
Ten en cuenta que esta consulta en particular recupera específicamente los componentes individuales de un anuncio de texto expandido, que se ven renderizados juntos en la pantalla de la IU Anuncio.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group_ad.ad.expanded_text_ad.headline_part1, ad_group_ad.ad.expanded_text_ad.headline_part2, ad_group_ad.ad.expanded_text_ad.headline_part3, ad_group_ad.ad.final_urls, ad_group_ad.ad.expanded_text_ad.description, ad_group_ad.ad.expanded_text_ad.description2, campaign.name, ad_group.name, ad_group_ad.policy_summary.approval_status, ad_group_ad.ad.type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM ad_group_ad WHERE segments.date DURING LAST_7_DAYS AND ad_group_ad.status != 'REMOVED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group_ad.ad.expanded_text_ad.headline_part1, ad_group_ad.ad.expanded_text_ad.headline_part2, ad_group_ad.ad.expanded_text_ad.headline_part3, ad_group_ad.ad.final_urls, ad_group_ad.ad.expanded_text_ad.description, ad_group_ad.ad.expanded_text_ad.description2, campaign.name, ad_group.name, ad_group_ad.policy_summary.approval_status, ad_group_ad.ad.type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM ad_group_ad WHERE segments.date DURING LAST_7_DAYS AND ad_group_ad.status != 'REMOVED' " }'
Palabras clave de la Búsqueda
Pantalla de descripción general predeterminada de las palabras clave de la Búsqueda en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group_criterion.keyword.text, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.keyword.match_type, ad_group_criterion.approval_status, ad_group_criterion.final_urls, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM keyword_view WHERE segments.date DURING LAST_7_DAYS AND ad_group_criterion.status != 'REMOVED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group_criterion.keyword.text, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.keyword.match_type, ad_group_criterion.approval_status, ad_group_criterion.final_urls, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM keyword_view WHERE segments.date DURING LAST_7_DAYS AND ad_group_criterion.status != 'REMOVED' " }'
Términos de búsqueda
La pantalla de resumen predeterminada de los términos de búsqueda en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT search_term_view.search_term, segments.keyword.info.match_type, search_term_view.status, campaign.name, ad_group.name, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM search_term_view WHERE segments.date DURING LAST_7_DAYS
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT search_term_view.search_term, segments.keyword.info.match_type, search_term_view.status, campaign.name, ad_group.name, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM search_term_view WHERE segments.date DURING LAST_7_DAYS " }'
Públicos
La pantalla Descripción general de los públicos predeterminada en la IU.
Ten en cuenta que la API de informes muestra los públicos en función de los IDs de los criterios. Para obtener
los nombres para mostrar, busca los ID en las tablas de referencia que se proporcionan en la
Códigos y formatos. Puedes
desactiva el campo ad_group_criterion.type
para determinar qué tipo de criterios
tabla para usar.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group_criterion.resource_name, ad_group_criterion.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM ad_group_audience_view WHERE segments.date DURING LAST_7_DAYS
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group_criterion.resource_name, ad_group_criterion.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM ad_group_audience_view WHERE segments.date DURING LAST_7_DAYS " }'
Edad (datos demográficos)
La pantalla de resumen predeterminada de los datos demográficos por edad en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group_criterion.age_range.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM age_range_view WHERE segments.date DURING LAST_7_DAYS
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group_criterion.age_range.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM age_range_view WHERE segments.date DURING LAST_7_DAYS " }'
Género (datos demográficos)
La pantalla de resumen predeterminada de los datos demográficos por género en la IU.
Pantalla de IU
Consulta a la API
GAQL
SELECT ad_group_criterion.gender.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM gender_view WHERE segments.date DURING LAST_7_DAYS
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT ad_group_criterion.gender.type, campaign.name, ad_group.name, ad_group_criterion.system_serving_status, ad_group_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.advertising_channel_type FROM gender_view WHERE segments.date DURING LAST_7_DAYS " }'
Ubicaciones
La pantalla Descripción general de las ubicaciones predeterminada en la IU
Ten en cuenta que la API de informes devuelve ubicaciones según sus IDs de criterio. Para obtener
sus nombres visibles, busca
campaign_criterion.location.geo_target_constant
en la segmentación geográfica
datos o usa la API para consultar
geo_target_constant
.
Pantalla de IU
Consulta a la API
GAQL
SELECT campaign_criterion.location.geo_target_constant, campaign.name, campaign_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM location_view WHERE segments.date DURING LAST_7_DAYS AND campaign_criterion.status != 'REMOVED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT campaign_criterion.location.geo_target_constant, campaign.name, campaign_criterion.bid_modifier, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM location_view WHERE segments.date DURING LAST_7_DAYS AND campaign_criterion.status != 'REMOVED' " }'
Cómo buscar constantes geográficas
La página Códigos y formatos brinda tablas de referencia de la mayoría de las constantes que se usan en la API. Sin embargo, también puedes buscar de forma dinámica algunas constantes con el lenguaje de consulta de Google Ads.
En esta muestra, se indica cómo buscar una ubicación por nombre de recurso o por su nombre visible.
Por nombre de recurso
Busca Mountain View, CA, por su nombre de recurso geoTargetConstants/1014044
.
GAQL
SELECT geo_target_constant.canonical_name, geo_target_constant.country_code, geo_target_constant.id, geo_target_constant.name, geo_target_constant.status, geo_target_constant.target_type FROM geo_target_constant WHERE geo_target_constant.resource_name = 'geoTargetConstants/1014044'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data "{ \"query\": \" SELECT geo_target_constant.canonical_name, geo_target_constant.country_code, geo_target_constant.id, geo_target_constant.name, geo_target_constant.status, geo_target_constant.target_type FROM geo_target_constant WHERE geo_target_constant.resource_name = 'geoTargetConstants/1014044' \" }"
Por nombre visible
Busca "Mountain View". como nombre de ciudad en Estados Unidos.
GAQL
SELECT geo_target_constant.canonical_name, geo_target_constant.country_code, geo_target_constant.id, geo_target_constant.name, geo_target_constant.status, geo_target_constant.target_type FROM geo_target_constant WHERE geo_target_constant.country_code = 'US' AND geo_target_constant.target_type = 'City' AND geo_target_constant.name = 'Mountain View' AND geo_target_constant.status = 'ENABLED'
cURL
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/googleAds:searchStream" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data "{ \"query\": \" SELECT geo_target_constant.canonical_name, geo_target_constant.country_code, geo_target_constant.id, geo_target_constant.name, geo_target_constant.status, geo_target_constant.target_type FROM geo_target_constant WHERE geo_target_constant.country_code = 'US' AND geo_target_constant.target_type = 'City' AND geo_target_constant.name = 'Mountain View' AND geo_target_constant.status = 'ENABLED' \" }"