AdWords scripts AWQL snippets

Some examples of commonly used scripts and AWQL snippets for AdWords.

Get AWQL data with AdWords scripts

The script below is a Google Apps Script or AdWords script that finds all queries in a certain data range and puts them into an array.

/* get AWQL data example */

// empty array for pushing items
var selectedQueries = [];

// main function, will run automatically
function main() {
  findQueries();
}

function findQueries() {
  var awqlQueryResults = AdWordsApp.report(
    "SELECT Query, CampaignName " +
    "FROM   SEARCH_QUERY_PERFORMANCE_REPORT " +
    " WHERE " + 
    " CampaignName CONTAINS Search " +
    " DURING LAST_30_DAYS");
  
  var rows = awqlQueryResults.rows(); // var with all rows
  while (rows.hasNext()) { // loops through awql results
    var row = rows.next();
    var query = row['Query'];
    negativesArray.push(query);
  }
  Logger.log(negativesArray);
}

More examples

Some examples for specific purposes. See the AdWords API documentation for all available report types.

// shopping products data
select
	Clicks, ProductGroup, CpcBid, BenchmarkAverageMaxCpc, SearchClickShare, SearchImpressionShare
from PRODUCT_PARTITION_REPORT
where 
  CpcBid > 0
  and CampaignStatus = ENABLED
  and AdGroupStatus = ENABLED
during LAST_MONTH

// feed items such as sitelinks
select
	FeedItemId, Status, PlaceholderType
from PLACEHOLDER_FEED_ITEM_REPORT
during LAST_30_DAYS

// ad data
select
	AdGroupName, PolicySummary, Status
from AD_PERFORMANCE_REPORT
where 
  CombinedApprovalStatus != APPROVED
  AND Status != DISABLED
during TODAY