Skip to content

Instantly share code, notes, and snippets.

@derekmartinla
Created April 9, 2015 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save derekmartinla/c660f7d326a04e2d418e to your computer and use it in GitHub Desktop.
Save derekmartinla/c660f7d326a04e2d418e to your computer and use it in GitHub Desktop.
Ad-Group Callout Extension Example
// Set callout extensions on the ad group level for all active ad groups based on text sent in createCallouts()
// Change campaign selection criteria as needed
function main() {
campIter = AdWordsApp.campaigns().withCondition("CampaignName contains Brand").withCondition("CampaignName does_not_contain Remarketing").get();
var callouts = createCallouts();
while (campIter.hasNext()) {
camp = campIter.next();
agIter = camp.adGroups().withCondition("Status = ENABLED").get();
while(agIter.hasNext()) {
ag = agIter.next();
for (i = 0; i < callouts.length; i++) {
Logger.log(callouts[i]); // Verify that the callout was created
ag.addCallout(callouts[i].getResult());
}
}
}
}
function createCallouts() {
calloutObjects = [];
callout1 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout1);
callout2 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout2);
callout3 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout3);
callout4 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout4);
callout5 = AdWordsApp.extensions().newCalloutBuilder().withText("Senior Fitness").build();
calloutObjects.push(callout5);
callout6 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout6);
callout7 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout7);
callout8 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout8);
callout9 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout9);
callout10 = AdWordsApp.extensions().newCalloutBuilder().withText("This is your callout text.").build();
calloutObjects.push(callout10);
return calloutObjects;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment