Need To Pause Campaign, When Reached On Certain Conversion Number.

105 views
Skip to first unread message

Wmb analytics

unread,
Jul 29, 2021, 6:11:11 AM7/29/21
to Google Ads Scripts Forum
Hi,

I want to pause campaign when it reached on certain number on daily basis.

Here is my script, please do check and let me know if it is right or not, 

provide me script..

Campaign Name : CC Via QnP - Health - Display - 65 - 91
Pause When Conversion is more than 65



Script 


function main() {
  function pauseCampaign() {
  var campaignIterator = AdsApp.campaigns()
  .withCondition("Conversions > 65")
  .withCondition('Name = "CC Via QnP - Health - Display - 65 - 912"')
      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    campaign.pause();
  }
}
}

Google Ads Scripts Forum Advisor

unread,
Jul 29, 2021, 10:25:38 PM7/29/21
to adwords...@googlegroups.com
Hello,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

In your script, the function pauseCampaign must be called so it may execute at run time. Please see Calling functions for your reference. In addition, kindly take note that if a stats column is used in the condition which in your case the Conversions metric is used, then the date range must be specified via CampaignSelector.forDateRange(String) or CampaignSelector.forDateRange(Object, Object).

Let me know how it goes.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2JEyk1:ref

Wmb analytics

unread,
Jul 30, 2021, 2:54:24 AM7/30/21
to Google Ads Scripts Forum on behalf of adsscripts
Hi,

I am not a developer, so can u help me with this.


My Concern is " Whenever Campaign name "AD Max"  is crossing "$200 cost"  Or cross  "50 conversions" (On Daily Basis)
then campaign "AD Max" should be paused also email notification should be sent on  "wmbana...@gmail.com ".

This is my current script, i want you to look and do the needful and and please sent me script which i can add it

function main()
{
  var campaignIterator = AdsApp.campaigns()
      .withCondition('Name = "AD Max"')

      .get();
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    var stats = campaign.getStatsFor('TODAY');
if(stats.getCost() >= 200)
campaign.pause();
  }
}



""



--
-- 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-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/Nwexz000000000000000000000000000000000000000000000QX1DEK00vdEtIWctQ56ndAnK6jasWA%40sfdc.net.

Google Ads Scripts Forum Advisor

unread,
Jul 30, 2021, 5:42:10 AM7/30/21
to adwords...@googlegroups.com
Hello,

Thanks for coming back. I would like to inform you that our team can only provide guidance on you can implement or make changes to your scripts. You can follow through the steps below to achieve you goal. For what it's worth, Google Ads Scripts only require entry-level familiarity with JavaScript so you should be able to complete your script in no time.
  • I see that you already have a condition to check if the Campaigns' cost is exceeding or equals to 200. You would actually do the same which checking Conversions through the getConversions method. 
  • After that in your condition, add a Logical OR (||) to combine your conditions. (Eg 'stats.getCost() >= 200 || stats.getConversions() >= 50').
  • Once your campaign gets paused, you can use the Mail Service to send you an email notification.
  • Here is an example on how to send a simple email that you can take a look at.
  • If you are satisfied with the script, you can schedule it to run at a Daily basis. See the Scheduling a script section in this link on how.
Let me know if you have questions.
Reply all
Reply to author
Forward
0 new messages