Common Use Case Example

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/v20/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 /v20/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.