In this post, we will cover how to suppress the email sends to a specific set of Subscribers using Exclusion scripts.
The Exclusion script is an optional section displayed when configuring an email send, where the AMPscript expressions can be added. The records are evaluated against the condition defined and if they result in 'true', they are excluded from the send.
This feature is available in the following applications:
1. Content Builder
Go to Email Studio
Under the Content Builder Emails tab, click on the email that needs to be sent
On the top-right, click on the 'Send' button
While configuring Step 2 (SELECT AUDIENCE), click on 'Advanced Exclusions' on the right-bottom to see the 'Exclusion Script' option.
2. Journey Builder
Go to the Journey
Click on the Email Activity and select the Email
Select the Delivery Options tab on the left to see the 'Exclusion Script' option.
3. Automation Studio
Go to Automation Studio
Drag the 'Send Email' Activity into the workflow
Create a new Email Activity or select an existing one and select the email
While configuring Step 3 (SELECT AUDIENCE), click on 'Advanced Exclusions' on the right-bottom to see the 'Exclusion Script' option.
Go to Email Studio
Hover over the Interactions tab and click User-Initiated Emails.
Enter the name and select an email
Under "Recipients," click Edit Recipients.
Select your recipient list.
Under "Audience Exclusion Script," click the plus sign (+) to expand the section
4. Triggered Sends
Go to Email Studio
Hover over the Interactions tab and click Triggered Sends.
Go to Exclusion Management | Exclusion Script.
Note - Exclusion Script may not be available as an option within the Email Activity. If this is the case, please reach out to Marketing Cloud Support to enable this feature.
Now, let's take a look at some of the examples to understand how this works.
Functions/Strings that are used in the examples below:
Empty - Check if the field value is empty
AttributeValue - Fetch the value for the field name specified
RowCount - Function to count the number of records
LookupRows - Function to lookup a Data Extension
DataExtension_Name - Exclusion Data Extension that includes set of Subscribers
Email_Field - Field Name used in the Data Extension
emailaddr - System defined string that checks for Subscriber's email addresses
Domain - Check the domain of an email
FormatDate - Used for Date formatting
AttributeValue("Points_Balance") < 0
This script checks if the Points balance for a subscriber is less than 0 and if it evaluates to true, they are excluded from the send.
This script checks if the Points balance for a subscriber is Empty. If there is no value, they are excluded from the send.
Domain(emailaddr) != "sfmcstack.com"
This script checks if the Email address of a subscriber has a domain other than 'sfmcstack.com'
firstname.lastname@example.org - Evaluates to false and email will be sent since the domain is 'sfmcstack.com'
email@example.com - Evaluates to true and will be excluded from the send, since the domain is 'sfmc.com'
AttributeValue("Points_Expiry_Date") < FormatDate(Now(),"YYYYMMDD")
This script checks if the Points_Expiry_Date for a subscriber is less than today's date. If it is expired, then they are excluded from the send.
This is script checks if the email address exists in a referenced data extension. If it does, then the count will be set to 1(True) and the Subscriber will be excluded from the send.
(RowCount(LookupRows("DataExtension_Name_1", "Email_Field", emailaddr)) > 0) OR (RowCount(LookupRows("DataExtension_Name_2", "Email_Field", emailaddr)) > 0)
If you want to check the email address in multiple Data Extensions, then use the expression including an OR/AND condition.
In this example, we will use a Code Snippet.
Code Snippet is basically a piece of content that can include HTML or AMPscript code and can be created using the below path:
Content Builder -> Create -> Content Blocks -> Code Snippet
Step 1 -
Add the below code to a Code Snippet block:
%%[ SET @count = RowCount(LookupRows("DataExtension_Name","Email_Field", emailaddr)) ]%% %%=v(@count)=%%
Step 2 -
The following exclusion script is then used to output the result from the Code Snippet:
TreatAsContent(ContentBlockbyId("CODE_SNIPPET_ID")) > 0
In addition to ContentBlockByID, the below two options can also be used:
ContentBlockByKey - Include Key of the Code Snippet
ContentBlockByName - Include Name of the Code Snippet
Things to Note -
1. AMPscipt block or inline delimiter cannot be included in Exclusion scripts
2. The expression must always evaluate as true or false
3. Using complex filters and/or filters on large tables can cause slow send speeds. The best practice is to pre-filter these subscribers before injecting them.
4. Even though exclusion scripts can be used with large non-triggered sends, all other methods generally perform and scale better (pre-segmentation, Suppression Lists, and Auto-Suppression Lists).
Hope you enjoyed it. Please feel free to drop a comment or contact me with any feedback or suggestions. See you in the next one!