Using an Exclusion Script for Email Sends

When sending emails ad-hoc or emails part of a Journey Builder send, you can use an exclusion script to exclude certain contacts from the email. An example use case is if you had two journeys: “Journey A” and “Journey B.” Suppose you wanted to keep contacts in Journey A from receiving certain emails if they are entered into Journey B. A simple way to do this is in your exclusion script, use a lookup to that Journey A Data Extension.

Example Exclusion Script


ROWCOUNT(LOOKUPROWS(“Journey_A_DE”, “Id”, _subscriberKey)) > 0


In this example, the data extension named “Journey_A_DE” contains the field name of “Id.” This field name “Id” is used as the SubscriberKey for this sendable data extension. The field name _subscriberkey is a personalization string. The AMPscript is using the RowCount function and if there is a match on that SubscriberKey then it will return a value of 1. Obviously 1 is greater than 0, so that means this specific contact would be excluded from the email send.

Example Exclusion Script with Multiple Data Extensions

Suppose you had multiple journeys and wanted to exclude a contact or subscriber from a send if they had already received an email in multiple journeys. You can nest the statements using an OR function:


(ROWCOUNT(LOOKUPROWS(“Journey_A_DE”, “Id”, _subscriberKey)) > 0) OR (ROWCOUNT(LOOKUPROWS(“Journey_C_DE”, “Id”, _subscriberKey)) > 0)


Note that the more data extensions you add to the exclusion script, the slower it runs. Depending on how many data extensions you want to exclude from, you may want to either JOIN it as an overall exclusion list or exclude these subscribers from your journey in SQL query.

Brand new SFMC instances do not have Exclusion Script enabled so if you do not see an option for exclusion scripts then you’ll have to reach out to Marketing Cloud Support for them to enable it.

Exclusion Script in Message Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *