Need Script to enable & pause Ads or Ad Groups based on Weather

469 views
Skip to first unread message

Jake

unread,
May 16, 2018, 5:15:12 PM5/16/18
to AdWords Scripts Forum
In need of a solution to pause or enable ads or ad groups based on weather. Ideally using labels to identify ads, but I will take possible solution.

I was working off this script (and got it to work):
but it only works on the campaign level.
and the Google Weather adwords script seems to work off bid adjustments only and unable to trigger ad copy directly.

I need something that works on ads directly or the ad group level, turning on / off based on weather conditions in a specific geolocation.

Please advise.
Thanks for your time.

Hiroyuki Miyauchi (AdWords Scripts Team)

unread,
May 16, 2018, 11:38:45 PM5/16/18
to AdWords Scripts Forum
Hello Jake,

If you are trying to use the script provided by "Jon" in the discussion you linked, you may modify the code below to fetch and update Ad groups. You may also refer to AdGroupSelectorAdGroup methods, AdSelector and Ad methods.

original code from the link you provided:
var campState = (precipitation > 0) ? true : false; //will be true if it's raining, false if not
var theCamp = AdWordsApp.campaigns()
   
.withCondition("Name = 'your campaign name'")
   
.get().next();

if (campState) {
    theCamp
.pause();
} else {
    theCamp
.enable();
}

modified code to fetch and update Ad groups:
var adGrpState = (precipitation > 0) ? true : false; //will be true if it's raining, false if not
var theAdGroup = AdWordsApp.adGroups()
   
.withCondition("CampaignName = 'INSERT_YOUR_CAMPAIGN_NAME' AND Name = 'INSERT_YOUR_ADGROUP_NAME'")
   
.get().next();

if (adGrpState) {
   
theAdGroup.pause();
} else {
   
theAdGroup.enable();
}

I would suggest that you test this script using the Preview button first to see possible changes.

Also, you may have a look on the generic version of the Weather-based Campaign Management that also discusses the management of campaigns and adGroups.

Please let me know how it goes after doing the suggestion.

Regards,
Hiroyuki
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages