Last September we
launched AdWords scripts, giving advertisers the power to solve complex advertising problems by writing simple JavaScript programs. Based on your
feedback, we’re happy to announce three new features in AdWords scripts: ad group creation, support for labels and new Google Analytics metrics.
Creating ad groups
Using an
AdGroupBuilder from a specific campaign allows you to create ad group programmatically. You can specify all or just some of the fields that make up an ad group. Calling the create() function of the builder returns the new ad group so you can start using the ad group immediately. Here’s an example of how to use it:
var adGroupBuilder = campaign.newAdGroupBuilder()
.withName('New York')
.withKeywordMaxCpc(1)
// Start off paused - let's review before launching this ad group!
.withStatus('PAUSED');
var newAdGroup = adGroupBuilder.create();
newAdGroup.createKeyword('pizza');
Now that you can create ad groups in addition to keywords and ads, copying entire ad groups to another campaign should be a snap!
Working with labels
Labels have been available in the UI for some time. AdWords Scripts is now providing a way to use them programmatically. They can be associated with Campaigns, Ad Groups, Keyword and Text Ads. You can create and remove labels as well as filter campaigns, keywords, etc. based on their label. You can also list, apply or remove labels associated with an entity.
Creating/removing a label:
AdWordsApp.createLabel("Poor performers",
"Keywords that have been performing poorly", "red");
var label = AdWordsApp.labels().
withCondition("LabelName EQUALS 'Foo'").get().next();
label.remove();
Apply or remove labels on objects:
keyword.applyLabel('Poor performers');
keyword.removeLabel('Poor performers');
Filtering with labels:
var label = AdWordsApp.labels().
withCondition("LabelName EQUALS 'Foo'").get().next();
var keywordsIter = label.keywords().get();
var keywordsIter = AdWordsApp.keywords().
withCondition("LabelNames CONTAINS_ANY ['Foo', 'Bar']").get();
Getting a list of labels on a keyword:
var labelIter = keyword.labels().get();
while (labelIter.hasNext()) {
Logger.log(labelIter.next().getName());
}
New analytics columns
If you have
linked your AdWords account with your Analytics account, you will be able to access bounce rate, average time on site, and average pageviews from the Stats object associated with AdWords entities. For example:
var stats = keyword.getStatsFor("LAST_7_DAYS");
Logger.log(stats.getBounceRate());
Logger.log(stats.getAverageTimeOnSite());
Logger.log(stats.getAveragePageviews()));
More resources
Please take advantage of AdWords scripts resources:
- Kevin Winter, AdWords Scripts Team