Reports provide information about all the different resources in your account. You can fetch information about campaigns, ad groups, and their stats, change history for your account, and more. The reporting infrastructure is backed by the Google Ads API and uses GAQL to specify what fields, metrics, and conditions you want to set.
Report vs. search
There are two main mechanisms for reporting. They both accept the same kinds of queries, and differ primarily in how they return the results.
For both cases, we will use the following query:
SELECT
campaign.id,
campaign.status,
metrics.clicks,
metrics.impressions,
customer.id
FROM campaign
WHERE
metrics.impressions > 0
AdsApp.report()
- This will return a flat, dictionary-like representation of your search
results. You can access fields as if using a dictionary, such as
row["campaign.id"]
androw["metrics.impressions"]
directly. By using this format, you can export the results directly to a spreadsheet using theexportToSheet()
method. This is not the native format that results are returned in by the Google Ads API, so in some cases some fields may not be available in this format. If that is the case, you should usesearch
instead. AdsApp.search()
- This will return a list of
GoogleAdsRow
objects, which have various fields, each of which may have sub-fields. So you would accessrow.campaign.id
androw.metrics.impressions
to fetch the data. This is generally more useful if you plan to process the data programmatically, and some fields may only be available in thesearch
format if they cannot be converted to a flat representation.
Report Example
let report = AdsApp.report(
"SELECT " +
" ad_group.id, search_term_view.search_term, metrics.ctr, metrics.cost_micros, metrics.impressions " +
"FROM search_term_view " +
"WHERE metrics.impressions < 10 AND segments.date DURING LAST_30_DAYS");
let rows = report.rows();
while (rows.hasNext()) {
let row = rows.next();
let query = row["search_term_view.search_term"];
let impressions = row["metrics.impressions"];
}
Take a look at the
AdsApp.report
documentation for full details on using this view.
Search Example
let search = AdsApp.search(
"SELECT " +
" ad_group.id, search_term_view.search_term, metrics.ctr, metrics.cost_micros, metrics.impressions " +
"FROM search_term_view " +
"WHERE metrics.impressions < 10 AND segments.date DURING LAST_30_DAYS");
while (search.hasNext()) {
let row = search.next();
let query = row.searchTermView.searchTerm;
let impressions = row.metrics.impressions;
}
Consult the full
Adsapp.search
documentation for all possible settings.