Date post: | 15-Jul-2015 |
Category: |
Technology |
Upload: | supergigas |
View: | 1,397 times |
Download: | 5 times |
Scripts UpdateLightweight solution for account management
Zhuo Chen
Agenda
● Brief recap
● New features
● Demo
● Resources
● Q&A
Recap(from last workshop)
Capabilities
● No need for dev token
● Simple JavaScript Code
● Integrated IDE
● Preview mode
● Scheduled run
● External data source
Sample AdWords Script
Print all campaign names under current accountfunction 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());
}
}
Sample MCC Script
Print stats of all accounts under current MCCfunction 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()); }}
Limits
● Execution time
● Entities
● Quota of underlying Google services
● More details: doc
New features
New Features
● Bulk upload
● Display criteria
● Shopping campaigns
● Google services integration
● Upgraded URLs
New Features (Cont.)
● Many more:○ Account label
○ Ad customizer
○ Ad extension - review, callout
○ Entity builder
○ Bidding
○ ...
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
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();}
Display criteria
● Manage the following display criteria:
○ keywords
○ placements
○ topics
○ audiences
● Both positive and negative (exclude)
● References: doc, example
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());}
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
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(); ...}
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); }}
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
Advanced APIs
● Enablement:○ Advanced APIs button -> Google Developers Console link
● Considerations:○ Authorization○ Permission○ Quota○ Billing
● References: doc, examples
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]);}
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: '[email protected] '}, {email: '[email protected]' }], // 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());}
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
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();
Resources
Documentation
Code snippets
Code snippets
Solutions
Forum
https://groups.google.com/forum/#!forum/adwords-scripts
Resources● Documentation● Code samples● Solutions● Forum● 3rd Party Solution