Adwords will overspend your account, this script will stop your campaigns when you have reached your daily budget.
function main() { // GET THE TOTAL SPEND OF THE ACCOUNT var costReport = AdWordsApp.report("Select Cost from ACCOUNT_PERFORMANCE_REPORT DURING TODAY"); var reportRow = costReport.rows().next(); var totalCost = reportRow["Cost"].replace(',', ''); // Remove thousand separator // PAUSE THE ACTIVE CAMPAIGNS IF THE BUDGET IS REACHED. REPLACE "XXXX" WITH YOUR BUDGET. if (totalCost > 400){ var campaignIterator = AdWordsApp.campaigns().withCondition("Status = ENABLED").get(); while (campaignIterator.hasNext()){ var campaign = campaignIterator.next(); campaign.pause(); } } } |
Archives
December 2017
Categories
All
|