Este sitio web utiliza cookies para realizar análisis y mediciones de tus visitas. [ Acepto ] [ Más información aquí ].

How to create a budget depletion alert in Adwords

This script will send to you an alert each time a daily budget goes depleted in any campaign of your Google Adwords account. This is a very powerful tool, since it will allow you to act inmediately by increasing the daily budget and/or reducing your CPCs. To create this alert, follow these steps:

1. Go into your Google Adwords account, and then go to Campaigns > Bulk operations > Scripts > + Script

2. Copy and paste this code:

function main() {

var text_email = "";

var campaignsIterator = AdWordsApp.campaigns().forDateRange("TODAY").get();

while (campaignsIterator.hasNext()) {

var campaign = campaignsIterator.next();

var stats = campaign.getStatsFor("TODAY");

var name = campaign.getName();

var cost = stats.getCost();

var budget = campaign.getBudget();

if (cost >= budget) {

var text_email = text_email+"<tr><td style='text-align:right;'>"+name+"</td>

<td style='font-weight:strong'>Gasto: "+cost+"</td></tr>";

}

}

var table = "<table>"+text_email+"</table>";

if (text_email!="") {

MailApp.sendEmail({

to: 'youremail@gmail.com',

subject: 'Depleted Budget Alert',

htmlBody: text_email,

})

Logger.log(text_email);

}

}

3. Program the script to be run each hour. When a daily budget goes depleted, an email will arrive to you with the subject "Depleted Budget Alert", with all the details of that campaign.

Añadir comentario

Comentarios

2018-04-20 - Gabriel

Me aparece \"Unterminated string literal. (línea 11)\"

2018-04-20 - Daniel Piñero

¿Has modificado el código? ¿Me lo envías completo?

2019-09-22 - Mathieu

Hi, I had the same issue as Gabriel, and you have to remove the blank space thare is bewteen the ending and the opening balises.

2019-04-19 - Bruno

You need to put line 12 in the same line as 11. It will parse correctly then.

2019-07-28 - Helpful Stranger

htmlBody should be set to the table variable inside the MailApp.sendEmail() function