Ten przewodnik zawiera zestaw zapytań w języku zapytań Google Ads, które pokazują, jak zwracać te same dane co ekrany w interfejsie Google Ads, a także jak wyszukiwać stałe geograficzne. Możesz używać tych zapytań w niezmienionej formie lub jako punktu wyjścia do tworzenia własnych zapytań niestandardowych.
Kopiowanie ekranów interfejsu Google Ads
W tej sekcji znajdziesz przykłady zapytań do interfejsu API, które zwracają te same dane co domyślne ekrany interfejsu Google Ads. Jeśli tworzysz aplikację, która wyświetla dane i statystyki podobne do tych w Google Ads, te zapytania mogą Ci pomóc w pobieraniu analogicznych danych z interfejsu API.
Kampanie
Domyślny ekran Przegląd kampanii w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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' " }'
Grupy reklam
Domyślny ekran Przegląd grup reklam w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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' " }'
Reklamy
Domyślny ekran przeglądu reklam w interfejsie.
To konkretne zapytanie pobiera poszczególne komponenty reklamy, które są wyświetlane razem w kolumnie Reklama na ekranie interfejsu.
Ekran interfejsu
Zapytanie do interfejsu 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' " }'
Wyszukiwane słowa kluczowe
Domyślny ekran przeglądu słów kluczowych w sieci wyszukiwania w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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' " }'
Wyszukiwane hasła
Domyślny ekran przeglądu wyszukiwanych haseł w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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 " }'
Odbiorcy
Domyślny ekran Odbiorcy ogółem w interfejsie.
Interfejs Reporting API zwraca odbiorców według identyfikatorów kryteriów. Aby uzyskać nazwy wyświetlane, wyszukaj identyfikatory w tabelach referencyjnych na stronie Kody i formaty. Możesz użyć pola ad_group_criterion.type
, aby określić, której tabeli typu kryteriów użyć.
Ekran interfejsu
Zapytanie do interfejsu 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 " }'
Wiek (dane demograficzne)
Domyślny ekran przeglądu danych demograficznych według wieku w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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 " }'
Płeć (dane demograficzne)
Domyślny ekran przeglądu danych demograficznych według płci w interfejsie.
Ekran interfejsu
Zapytanie do interfejsu 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 " }'
Lokalizacje
Domyślny ekran Przegląd lokalizacji w interfejsie.
Interfejs Reporting API zwraca lokalizacje według identyfikatorów kryteriów. Aby uzyskać nazwy wyświetlane, wyszukaj campaign_criterion.location.geo_target_constant
w danych kierowania geograficznego lub użyj interfejsu API, aby wysłać zapytanie do zasobu geo_target_constant
.
Ekran interfejsu
Zapytanie do interfejsu 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' " }'
Sprawdzanie stałych geograficznych
Na stronie Kody i formaty znajdziesz tabele referencyjne większości stałych używanych w interfejsie API. Możesz jednak dynamicznie wyszukiwać niektóre stałe za pomocą języka zapytań Google Ads.
Ten przykład pokazuje, jak wyszukać lokalizację według nazwy zasobu lub nazwy wyświetlanej.
Według nazwy zasobu
Wyszukaj Mountain View w Kalifornii według nazwy zasobu 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' \" }"
Według wyświetlanej nazwy
Wyszukaj „Mountain View” jako nazwę miasta w Stanach Zjednoczonych.
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' \" }"