Hi AdWords Scripts Group,
I notice that many of the script samples are geared for making individual actions, as opposed to account-wide changes.
For example AdWordsApp. CampaignSelector has with.conditions to filter specific campaigns.
In the below script example, the default template sample script is to add a phone number to one campaign.
I would prefer to add this to all campaigns at once- as I would typically add phone numbers to all campaigns (Or, at least all search campaigns).
I would always use the same phone number (Unless there were local offices). The same would apply to many other ad extensions- (unless product or service specific).
I thought of a few scenarios such as campaign does not contain, impressions > 10, label name contains or does not contain etc, etc.
However, I can't quite get the selector to filter the TRUE campaigns- and then apply the action (e.g. Apply phone ad extension to all campaigns- or just a wider filter than one entity).
can you advise,
Thanks
// --------
function main() {
addPhoneNumber();
}
function addPhoneNumber() {
var campaignIterator = AdWordsApp.campaigns()
.withCondition("LabelNames CONTAINS_ANY ['all', 'any']") // .withCondition('Name = "Text Ads Search UK"') removed the default with condition
.get();
if (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
var phoneNumberBuilder = AdWordsApp.extensions().newPhoneNumberBuilder();
var newPhoneNumber = phoneNumberBuilder
.withCountry('GB')
.withPhoneNumber('01899999999') // example phone number
.build()
.getResult();
// Add phone number to campaign. Adding phone number to ad group is
// similar.
campaign.addPhoneNumber(newPhoneNumber);
}
}