AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Ads
5.1K members online now
5.1K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

AdWords Script that pauses (and re-enables) campaigns based on RSS feed entries

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am attempting to create a script that will pause all campaigns when the RSS feed from a local weather service signals a "rainstorm warning". I'd also like to re-enable the previously paused campaigns once the rainstorm warning is over.

 

I've have re-purposed some other scripts that I have found online, but am not quite there yet. Below is my progress so far. Any help is appreciated.

 

 

function main() {
 
 // Load an XML file:
 var xmlURL = "http://rss.weather.gov.hk/rss/WeatherWarningBulletin.xml";
 var xmlFile = UrlFetchApp.fetch(xmlURL);
 
 // Parse the XML file:
 var document = XmlService.parse(xmlFile);
 var root = document.getRootElement();
 
 // Go through all children of <deepdive_pages>:
 var entries = document.getRootElement().getChildren();
 
 for (var i = 0; i < entries.length; i++) {
 //for (var i = 0; i < 10; i++) {
 var description = entries[i].getChild('description').getValue();
 
 // If description includes Rainstorm Warning
 if (description = "amber rainstorm warning"){
 var campaigns = AdWordsApp.campaigns().get();
 while (campaigns.hasNext()) {
 campaigns.next().pause();

}
 }
   } // End If Else
 }

 

1 Expert replyverified_user

AdWords Script that pauses (and re-enables) campaigns based on RSS feed entries

Top Contributor
# 2
Top Contributor