Questa guida fornisce un insieme di query nel linguaggio di query di Google Ads che dimostrano restituire gli stessi dati delle schermate nell'interfaccia utente di Google Ads e costanti geografiche. Puoi utilizzare queste query così come sono o come punto di partenza per creare le tue query personalizzate.
Replica delle schermate dell'interfaccia utente di Google Ads
Questa sezione illustra le query API che restituiscono gli stessi dati dei valori predefiniti. schermate dell'interfaccia utente di Google Ads. Se stai creando un'app che mostra metriche e dati in modo simile a Google Ads, queste query possono aiutarti a ottenere dati analoghi dall'API.
Campagne
La schermata predefinita Panoramica delle campagne nell'interfaccia utente.
Schermata UI
Query 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' " }'
Gruppi di annunci
La schermata predefinita della panoramica dei gruppi di annunci nell'interfaccia utente.
Schermata UI
Query 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' " }'
Annunci
La schermata predefinita Panoramica degli annunci nell'interfaccia utente.
Tieni presente che questa query specifica recupera in modo specifico i singoli componenti di un annuncio di testo espanso, che vengono visualizzati insieme nella schermata Colonna Annuncio.
Schermata UI
Query 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' " }'
Parole chiave per la rete di ricerca
La schermata della panoramica delle parole chiave per la rete di ricerca predefinite nell'interfaccia utente.
Schermata UI
Query 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' " }'
Termini di ricerca
La schermata della panoramica predefinita sui termini di ricerca nell'interfaccia utente.
Schermata UI
Query 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 " }'
Segmenti di pubblico
La schermata predefinita Panoramica dei segmenti di pubblico nell'interfaccia utente.
Tieni presente che l'API di reporting restituisce i segmenti di pubblico in base agli ID criterio. Per ottenere
i nomi visualizzati, cerca gli ID nelle tabelle di riferimento fornite
Pagina Codici e formati. Puoi
chiave fuori dal campo ad_group_criterion.type
per determinare il tipo di criteri
la tabella da utilizzare.
Schermata UI
Query 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 " }'
Età (dati demografici)
La schermata predefinita di panoramica sui dati demografici dell'età nell'interfaccia utente.
Schermata UI
Query 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 " }'
Genere (dati demografici)
La schermata predefinita della panoramica sui dati demografici di genere nell'interfaccia utente.
Schermata UI
Query 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 " }'
Località
La schermata predefinita Panoramica delle posizioni nell'interfaccia utente.
Tieni presente che l'API di reporting restituisce le località in base agli ID criterio. Per ottenere
i nomi visualizzati, cerca
campaign_criterion.location.geo_target_constant
nel targeting geografico
di archiviazione dei dati o utilizzare l'API per eseguire query
geo_target_constant
risorsa.
Schermata UI
Query 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' " }'
Ricerca delle costanti geografiche
La pagina Codici e formati fornisce tabelle di riferimento per la maggior parte delle costanti utilizzate nell'API. Tuttavia, puoi anche cercare in modo dinamico alcune costanti con il linguaggio di query di Google Ads.
Questo esempio mostra come cercare una località in base al nome della risorsa o al suo il nome visualizzato.
Per nome della risorsa
Cerca Mountain View, CA, dal nome della risorsa 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' \" }"
Per nome visualizzato
Cerca "Mountain View" come nome di città negli Stati Uniti.
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' \" }"