function main() {
//update the value of dailyBudget based on your requirement
var dailyBudget = 100;
var adGroupIterator = AdWordsApp.adGroups()
.withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"') //you may change this depending on your requirement
.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
Logger.log("AdGroup Name : %s", adGroup.getName());
//use TODAY to get data for today
var adGroupCost = adGroup.getStatsFor('TODAY').getCost();
Logger.log("AdGroup Cost: %s", adGroupCost);
//if adGroupCost reached the defined dailyBudget, pause the current adGroup
if (adGroupCost >= dailyBudget){
adGroup.pause();
}
else {
//do something else
}
}
}
function main() {
//update the value of dailyBudget based on your requirement
var dailyBudget = 1000;
var adGroupIterator = AdWordsApp.adGroups()
.withCondition('CampaignName = "INSERT_CAMPAIGN_NAME_HERE"') //you may change this depending on your requirement
.get();
while (adGroupIterator.hasNext()) {
var adGroup = adGroupIterator.next();
Logger.log("AdGroup Name : %s", adGroup.getName());
//use TODAY to get data for today
var adGroupCost = adGroup.getStatsFor('TODAY').getCost();
Logger.log("AdGroup Cost: %s", adGroupCost);
//if adGroupCost reached the defined dailyBudget, pause the current adgroup
if (adGroupCost >= dailyBudget){
adGroup.pause();
}
//if adGroupCost is less than the defined budget
else if(adGroupCost < dailyBudget){
adGroup.enable();
}
}
}
Please take note of the following:
- Assuming that you will schedule the script to run Hourly, and you will set a fresh budget daily (the else-if condition will then be satisfied), then the adgroups will be enabled for the next day.
- I would suggest for you to Preview the script above to see if it is within your requirements.
//you may change 'SAMPLE' to any word based on your requirements and campaigns with that word will be ignored
var campaignNameDoesNotContain = ["SAMPLE"];
.withCondition('CampaignName DOES_NOT_CONTAIN '+campaignNameDoesNotContain)
//you may change 'SAMPLE' to any word based on your requirements and campaigns with that word will be the only ones fetched
var campaignNameContains = ["SAMPLE"];
.withCondition('CampaignName CONTAINS '+campaignNameContains)
//you may change the status to PAUSED or REMOVED depending on your requirement
var ignorePausedCampaigns = 'ENABLED';
.withCondition('CampaignStatus = '+ignorePausedCampaigns)
function main() {
//update the value of dailyBudget based on your requirement
var dailyBudget = 100;
var campaignNameContains = ["Thea"];
var ignorePausedCampaigns = 'ENABLED';
var ignorePausedCampaigns = 'ENABLED';
var ignoreRemovedCampaigns = 'ENABLED';
var adGroupIterator = AdWordsApp.adGroups()
.withCondition('CampaignName CONTAINS '+campaignNameContains)
.withCondition('CampaignStatus = '+ignorePausedCampaigns)
.withCondition('CampaignStatus = '+ignorePausedCampaigns)
.withCondition('CampaignStatus = '+ignoreRemovedCampaigns)
--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scripts+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/9cfdf1e2-21de-40d0-9723-6b3801b441fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.