function main() {
Logger.log("**********************");
Logger.log("Running BUDGET - Pause All Campaigns script...");
Logger.log("**********************");
// THIS AMOUNT WILL VARY CLIENT BY CLIENT
// MAKE SURE IT IS CORRECT
var dailyBudget = 0;
var campaignIterator = AdWordsApp.campaigns().get();
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
//Use TODAY to get data on the date today
var stats = campaign.getStatsFor('TODAY');
var campaignCost = stats.getCost();
Logger.log("=================================");
Logger.log("Campaign: " + campaign.getName());
Logger.log("Cost: " + campaignCost);
//COMPARE current campaignCost and dailyBuddget variable
if (campaignCost >= dailyBudget){
Logger.log("Daily budget reach! Pausing campaign");
campaign.pause();
}
Logger.log("=================================");
}
}
|
||||||
Hi Teejay,
Thank you for helping !
Almost.. Its pausing individual campaigns that are over $X. For example I set X to be $5.. and it paused the remaketing campaign.. What I wanted it to do is when the campaign total for today is over X ($5) pause all campaigns. See here for what I mean..

Regards
George
--
-- 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 a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/t8P4mqsO50M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/rHm2U000000000000000000000000000000000000000000000QHVKI400KO-BABUXQ4KWej4aCy8qJg%40sfdc.net.
function main() {
Logger.log("**********************");
Logger.log("Running BUDGET - Pause All Campaigns script...");
Logger.log("**********************");
// THIS AMOUNT WILL VARY CLIENT BY CLIENT
// MAKE SURE IT IS CORRECT
var dailyBudget = 0;
//This variable holds the total cost for all campaigns
var totalCampaignCost = 0;
var campaignIterator = AdWordsApp.campaigns().get();
while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
//Use TODAY to get data on the date today
var stats = campaign.getStatsFor('TODAY');
var campaignCost = stats.getCost();
Logger.log("=================================");
Logger.log("Campaign: " + campaign.getName());
Logger.log("Cost: " + campaignCost);
Logger.log("=================================");
totalCampaignCost = totalCampaignCost + campaignCost;
}
Logger.log("Total Daily Campaign Cost: "+totalCampaignCost);
if(totalCampaignCost >= dailyBudget ){
Logger.log("Daily budget reach! Pausing all campaigns");
var campaignIterator = AdWordsApp.campaigns().get();
while(campaignIterator.hasNext()){
var campaign = campaignIterator.next();
Logger.log("Pausing Campaign: " + campaign.getName());
campaign.pause();
}
}
}
Hope this helps.
|
||||||
Hi Mark,
You guys are champions! Yes this worked a treat.. Many thanks for your help.. See results below..

Kind Regards,
George Katsoudas | LCS Partner
Lead generation through website SEO & AdWords
W: lowcostseoplans.com
Office: 200 Barangaroo Ave, Sydney NSW 2000

From: Google Ads Scripts Forum on behalf of adsscriptsforumadvisor <adwords...@googlegroups.com>
Sent: Friday, 9 October 2020 4:00 PM
To: adwords...@googlegroups.com
Subject: RE: Script to pause all campaigns based on daily budget total set
Hi George,
--
-- 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 a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/t8P4mqsO50M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/jC0XW000000000000000000000000000000000000000000000QHX4KT00mjde12sITfyWvrsXW9koCQ%40sfdc.net.