AI-generated Key Takeaways
-
This page provides a Google Ads Query Language (GAQL) query to retrieve a 30-day performance summary of an account, segmented by campaign and device.
-
You can execute this query using the
GoogleAdsService.SearchStream
interface within the Google Ads API. -
The page includes a complete HTTP request example, but it's recommended to utilize client libraries for seamless integration within applications.
-
Code samples and a video walkthrough demonstrating campaign searches with metrics are also available for reference.
This use case summarizes the performance of an account over the last 30 days by campaign, segmented by device. The query for this report is as follows:
SELECT
campaign.name,
campaign.status,
segments.device,
metrics.impressions,
metrics.clicks,
metrics.ctr,
metrics.average_cpc,
metrics.cost_micros
FROM campaign
WHERE segments.date DURING LAST_30_DAYS
To issue this request, pass this Google Ads Query Language statement to the
GoogleAdsService.SearchStream
interface.
HTTP request URL
The request consists of an HTTP POST to the Google Ads API server at the following URL:
https://googleads.googleapis.com/v21/customers/{customer_id}/googleAds:searchStream
Complete HTTP request sample
Here is a complete example of this report definition, enclosed in an HTTP POST request.
POST /v21/customers/{customer_id}/googleAds:searchStream HTTP/1.1 Host: googleads.googleapis.com User-Agent: curl Content-Type: application/json Accept: application/json Authorization: Bearer [Enter OAuth 2.0 access token here] developer-token: [Enter developerToken here] Parameters: { "query" : "SELECT campaign.name, campaign.status, segments.device, metrics.impressions, metrics.clicks, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_30_DAYS" }
Code samples
Watch a video walkthrough of a code sample that searches campaigns with metrics over the last 7 days. This code sample is written in Java, but the process is similar for all languages.