Skip to main content

Actions

An action is what a rule does to a Facebook object when the condition is met. Inside the checkAd(ad) function you have ready-made functions available: to pause and to return to work — at three levels: ad, adset and campaign. If none of them is called, the rule changes nothing.

For how to write the rule itself — Creating a rule. The full reference of functions and fields — Automated rules SDK.

Pause

Ad — pauseAd

Pauses the current ad (the one being checked right now).

JavaScript
pauseAd('24h', 'нет депов при расходе > 100');
  • The first argument — the pause duration ('6h', '12h', '24h', 'next_day_target_geo', 'next_day_ad_account', 'permanent', 'while_matches'). Read more — Scheduling and pauses.
  • The second argument — the reason (optional). The text goes into the Logs (it is recorded with the action in Facebook). If not specified — the rule name is substituted.

Adset — pauseAdset

Pauses an adset. An adset has no "own" current object, so the arguments are passed as an object, and the adsetId field is required:

JavaScript
pauseAdset({ adsetId: ad.adset_id, duration: '24h', reason: 'весь адсет в минус' });

Campaign — pauseCampaign

Pauses a campaign. The arguments are an object, the campaignId field is required:

JavaScript
pauseCampaign({ campaignId: ad.campaign_id, duration: 'permanent', reason: 'кампания убыточна' });

All three levels — pauseAd, pauseAdset and pauseCampaign — are applied automatically in the real check cycle, and are also checked on the Test tab.

Return to work

In most cases you do not need to return an ad manually: Britva does it itself — when the pause term expires or when the rule condition stops being met (for the "while the condition matches" pause type).

You can lift a pause by hand on the Paused tab — the Activate button.

Return from code

The SDK also has return functions — activateAd and counterparts for the adset and campaign — that lift a hold from code. They work in the real check cycle. But in most cases you do not need them: ads are returned automatically when the pause expires or when the condition stops triggering, so rules with a pause are enough for normal operation.

What's next