Hi,
Thanks for reaching out and allow me to assist you in this. The CampaignSelector only allows you to fetch Search and Display campaigns. With that said, there are separate campaign selectors that you should you use to check/pause video and shopping campaigns which is the VideoCampaignSelector and the ShoppingCampaignSelector.
Let me know if you have other questions.
Thanks,
|
||||||
Hi there,
Sure. I have tweaked your script and added a selector array to loop through the three campaign selectors. You would just need to identify in which condition you would like to receive the email notification. Please see below code for your reference. Let me know if this would work on your end.
var accountBudgetLimit = 0; // set your account budget limit here
var accountCampaignsCost = 0;
// gets all the campaigns of the account. You may add conditions to select campaigns using withCondtion()
var selectors = [AdsApp.campaigns(), AdsApp.videoCampaigns(), AdsApp.shoppingCampaigns()];
for(var i = 0; i < selectors.length; i ++) {
var campaigns = selectors[i].get();
/*
* This While-loop sums the costs garnered by all
* the campaigns of the account for the specified date range
*
*/
while (campaigns.hasNext()) {
var campaign = campaigns.next();
var stats = campaign.getStatsFor("THIS_MONTH"); // gets stats for today, you may change the date range based on your requirment
accountCampaignsCost += stats.getCost(); // gets the cost of the campaign
if (accountCampaignsCost >= accountBudgetLimit) { // If the total costs of the campaign has reached or exceeded the specified limit, pause the camapaigns
Logger.log("Campaign " + campaign.getName() + " has exceeded budget limit. Pausing campaign...");
campaign.pause(); // pauses the campaign
}
else {
Logger.log("Total spending of campaigns has not yet reached the account budget limit.");
}
}
// MailApp.sendEmail('info(A)website.com', // specify email address here
// 'Google Ads OVERSPENDING ALERT: ACCOUNT NAME monthly budget exceeded & all campaigns paused',
// 'The total cost of your campaigns has reached the specified limit.'); // notifies you with an email when total cost of the campaigns has reached he specified limit. You may change the email message based on your preference.
}Hello,
Kindly share with us your CID and the script ID/Name via Reply privately to author or Reply to author option instead, so we could check on our end. If those options aren't working on your end, you can send those requested details on this email (googleadsscr...@google.com) and include the link of this thread so we could keep track of this existing conversation.
Hi Jochen,
Thanks for providing the requested details. However, it seems that the script is working as expected and does pause the campaigns based on your condition. Please see screenshot for your reference. Are there any thrown error messages at your end when running the script?
--
-- 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/b_0Nlu00rbc/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/VaULO000000000000000000000000000000000000000000000QLB79J00r-8HfNhbTTiEPq5Mlu1lpQ%40sfdc.net.
Hi Jochen,
Thanks for confirming. Kindly let me know if you still have any questions or concerns.
Hi Jochen,
Thanks for coming back. You may add a condition to your CampaignSelector by using the withCondition method to filter campaigns that are enabled. You may update line 9 with the following:
var campaigns = selectors[i].withCondition("Status = ENABLED").get();
Kindly try this at your end then let me know how it goes.
--
-- 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/b_0Nlu00rbc/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/-YCT5000000000000000000000000000000000000000000000QME12N00Joo2NBaESLuATtqzfIZwAQ%40sfdc.net.
Hi Jochen,
Thanks for coming back. I have made a couple of changes that should help us monitor why the script would not be able to pause the campaigns as intended. I have also changed the way we set value you to the accountCampaignsCost variable instead of summing up the cost every time, we should check individual cost since we there are multiple campaigns. Kindly see attached for your reference. Note that I have run tests and you may have received emails from the script so please disregard. Let me know how it goes this time, then we'll go from there.
--
-- 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/b_0Nlu00rbc/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/55_7o000000000000000000000000000000000000000000000QO6ZJ100kmCEH2MiRTKDtvN1lNermQ%40sfdc.net.
Hi Jochen,
We can't really make changes for you. You may choose to update the script on your end based on my suggestions. Let me know how it goes.
--
-- 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/b_0Nlu00rbc/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/1upgj000000000000000000000000000000000000000000000QO74IU00vhQOFstZQz2KanqLb_imGA%40sfdc.net.
Hi Jochen,
Thanks for your patience on this. Can I interest you in looking at the cost of the Account level instead of summing up the cost of each campaign? I assume that you would like to pause all campaigns based on account's cost spent as a whole, regardless if a campaign or two has not exceeded its budget. I have revised the script in this regard. Please see attached. Let me know how it goes.
--
-- 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/b_0Nlu00rbc/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/2Ucaw000000000000000000000000000000000000000000000QOAM7G00Vba8F69nRwGSkcSmHjBP6Q%40sfdc.net.
Hi Jochen,
Thanks for bringing that up. Upon checking with the team, this would consider all costs spent for the whole account. Let me suggest another revision to your script. I think it would be best if we iterate through all of the campaigns' cost before having them paused instead. Would you agree? Please see attached and let me know your thoughts.
--
-- 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/b_0Nlu00rbc/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/BNHdU000000000000000000000000000000000000000000000QOCWEU00qXsWBdjfSNi1vX8wQzE9xw%40sfdc.net.