4. Capabilities
● No need for dev token
● Simple JavaScript Code
● Integrated IDE
● Preview mode
● Scheduled run
● External data source
5. Sample AdWords Script
Print all campaign names under current account
function main() {
// Get all campaigns.
var campaignIterator = AdWordsApp.campaigns().get();
// iterate the list and print names to logger window.
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
Logger.log(campaign.getName());
}
}
6. Sample MCC Script
Print stats of all accounts under current MCC
function main() {
// Retrieve all the child accounts.
var accountIterator = MccApp.accounts().get();
// Iterate through the account list.
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Get stats for the child account.
var stats = account.getStatsFor("THIS_MONTH");
// And log it.
Logger.log("%s,%s,%s", account.getCustomerId(), stats.getClicks(),
stats.getImpressions(), stats.getCost());
}
}
9. New Features
● Bulk upload
● Display criteria
● Shopping campaigns
● Google services integration
● Upgraded URLs
10. New Features (Cont.)
● Many more:
○ Account label
○ Ad customizer
○ Ad extension - review, callout
○ Entity builder
○ Bidding
○ ...
11. Bulk Upload
● Make bulk changes by uploading data in CSV format
○ can be from many data sources
● Benefits:
○ Utilize new features
○ Easy to transform report data or change entities
○ Higher limits, both for quantities and time
● Support campaign management and offline
conversions
● References: doc, example
12. Bulk upload from Google Drive
function bulkUploadFromGoogleDrive() {
// Check document for the list of supported bulk upload templates.
// You can upload a CSV file, or an EXCEL sheet.
var SPREADSHEET_URL = 'INSERT_SPREADSHEET_URL_HERE';
var spreadSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = spreadSheet.getActiveSheet();
var upload = AdWordsApp.bulkUploads().newFileUpload(sheet);
upload.forCampaignManagement();
// Use upload.apply() to make changes without previewing.
upload.preview();
}
13. Display criteria
● Manage the following display criteria:
○ keywords
○ placements
○ topics
○ audiences
● Both positive and negative (exclude)
● References: doc, example
14. Add a placement in a campaign
function addPlacementToCampaign() {
var campaign = AdWordsApp.campaigns()
.withCondition("Name = 'INSERT_CAMPAIGN_NAME_HERE'")
.get().next();
// Other display criteria can be built in a similar manner using the
// corresponding builder method in the AdWordsApp.Display,
// AdWordsApp.CampaignDisplay or AdWordsApp.AdGroupDisplay class.
var placementOperation = campaign.display()
.newPlacementBuilder()
.withUrl('http://www.site.com') // required
.withCpc(0.50) // optional
.build();
var placement = placementOperation.getResult();
Logger.log('Placement with id = %s and url = %s was created.',
placement.getId(), placement.getUrl());
}
15. Shopping
● Work with existing shopping campaigns
● Create and manage product group hierarchies
● Run shopping reports
● Cannot:
○ Create shopping campaigns
○ Set shopping properties at the campaign level (e.g.
campaign priority, inventory filters, etc.)
○ Link Merchant Center accounts
● References: doc
16. Retrieve shopping entities
var campaignName = "My first shopping campaign";
var adGroupName = "My first shopping adgroup";
var adGroupIterator = AdWordsApp.shoppingAdGroups()
.withCondition("CampaignName = '" + campaignName + "'")
.withCondition("AdGroupName = '" + adGroupName + "'")
.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
...
}
17. Select specific product group
function main() {
var productGroups = AdWordsApp.productGroups()
.withCondition("Clicks > 5")
.withCondition("Ctr > 0.01")
.forDateRange("LAST_MONTH")
.get();
while (productGroups.hasNext()) {
var productGroup = productGroups.next();
productGroup.setMaxCpc(productGroup.getMaxCpc() + 0.01);
}
}
18. Google Services Integration
● External Data:
○ Spreadsheet, Drive, Charts, Email, URL fetching
● Advanced APIs:
○ Google Analytics
○ Google BigQuery
○ YouTube and YouTube Analytics
○ Fusion Tables
○ Google Calendar
○ Google Tasks
○ Google Prediction
20. Get stats for an Analytics profile
function getStatsForProfileId() {
var profileId = 'INSERT_PROFILE_ID_HERE';
// Dates should be in yyyy-mm-dd format.
var startDate = 'INSERT_START_DATE_HERE';
var endDate = 'INSERT_END_DATE_HERE';
var results = Analytics.Data.Ga.get('ga:' + profileId, startDate,
endDate, 'ga:sessions');
Logger.log('Profile Name: %s', results.profileInfo.profileName);
Logger.log('Total Sessions: %s', results.rows[0][0]);
}
21. Create event on a calendar
function createEvent() {
// You can find a Google Calendar's ID from its settings page.
var calendarId = 'INSERT_CALENDAR_ID_HERE' ;
// Apr 1, 2015 10:00:00 AM - Apr 1, 2015 11:00:00 AM
var start = new Date(2015, 3, 1, 10, 0, 0);
var end = new Date(2015, 3, 1, 11, 0, 0);
var calendarEvent = {
summary: 'Run account performance report' ,
description : 'Run account performance report for March.' ,
start: {dateTime: start.toISOString()},
end: {dateTime: end.toISOString()},
attendees: [{email: 'alice@example.com '}, {email: 'bob@example.com' }],
// Red background. Use Calendar.Colors.get() for the full list.
colorId: 11
};
calendarEvent = Calendar.Events.insert(calendarEvent, calendarId);
Logger.log('New event with ID = %s was created.' + calendarEvent .getId());
}
22. Upgraded URLs
● Separate landing URL and tracking URL
○ Less time to manage URL tracking updates
○ Reduce crawl and load time of website
○ New ValueTrack and custom tracking parameters
● Migration deadline: 1 July, 2015 (guide)
● References:
○ API: guide, migration guide
○ Scripts: blog post
23. Create a new text ad
var adOperation = adGroup.newTextAdBuilder()
.withHeadline("headline of ad")
.withDescription1("first line of ad description")
.withDescription2("second line of ad description")
.withDisplayUrl("www.example.com")
.withFinalUrl("http://www.example.com")
.build();
var ad = adOperation.getResult();