My business is trying to implement 2 rules on marketers about the frequency they can email our contacts in marketing cloud. I am looking for a solution to do this perhaps in automation studio to eliminate errors.

The first rule is that contacts can only receive one email per day - if they already received one, any subsequent sends for that contact would fail / be skipped record.

Second rule is that contacts can only receive two emails in a 7 day rolling period. If they already received 2 emails within the past 7 days, they would fail / be skipped record.

Our MC environment was set up to have a standard data extension that is populated from synchronized data extension on a daily basis. Marketers create filtered data extensions from the standard and then send to the filtered DE.

Problems this poses:

  1. Filtered data extension is static at time of creating - if I were to include a last sent date in the standard DE automation that uses tracking data, it would not prevent sends against previously filtered data extensions that are not refreshed.
  2. Marketers can schedule multiple emails on the same day or during the same 7-day period in the future - tracking tables that might be used for suppression don't contain jobs scheduled in future. Eg. Today is 8/25 and no email has been sent today. Marketer sets up three emails to be sent tomorrow - neither filter criteria would be met.

One possibility would be including an Exclusion Script in the email that filters out subscribers present in the sent data view with a date of the current day or in your second case the last 7 days.

According to Eliot's answer to another question the script needs to be saved to a content block and the return value (content) of this block needs to be used in the Exclusion script:

  var @test
  set @test = DateDiff(iif(RowCount(LookupOrderedRows('_Sent',1,'EventDate desc','SubscriberKey',_subscriberKey))==1,Field(Row(LookupOrderedRows('_Sent',1,'EventDate desc','SubscriberKey',_subscriberKey),1),'EventDate'),'1/1/2000'),SystemDateToLocalDate(Now()),'D')

And your exclusion script will look like this (for the 7 day check):

TreatAsContent(ContentBlockbyID('[ID_OF_YOUR_CONTENT_BLOCK]')) < 7

Related documentation:

  • Thank you, this was really helpful in figuring out the solution. I actually came up with an AMPScript that will abort the email for a single subscriber within a single content block. No exclusion script necessary. This would also work in guided sends and journey builder sends. Aug 26 '17 at 20:22
  • Letting a send error in order to filter subscribers isn't a good idea and far from best practice! Why don't you just use exclusion scripts? Aug 26 '17 at 20:34
  • Can you explain how to use exclusion scripts with a regular send? The only documentation I can find on it is about sending through User Interactions. Aug 27 '17 at 19:09
  • When performing a regular send you have to expand Advanced Options (bottom right corner) in the Select Audience wizard step. Then you will see a textbox with the label Exclusion Script. Aug 28 '17 at 8:34
  • I'm trying to create an easy way for non-technical marketers to use. The idea is not to use this content block as a suppression or segmentation tool - they know what they are supposed to be doing. This is just a safety net for them in case they make a segmentation error. Why is it bad practice to let the send error intentionally? Well more to the point, what are possible consequences of doing so? Aug 29 '17 at 12:39

I have modified Eliot Harper's AMPScript to work without any exclusion script.

The script will abort a send for an individual subscriber using RaiseError() function where the condition of time interval is met.

The send will then continue to the next record for evaluation. I've tested this in test and guided sends. The script can be used anywhere in the email. I was considering adding it to the saved template, but because of how long it takes to run when testing, I think I will create a content block that marketers can drag into their email before sending.

var @shortestInterval
SET @shortestInterval = 0
var @shortestPreviousInterval
SET @shortestPreviousInterval = 7
var @dayssincelastsend
IF RowCount(lookuporderedrows('_Sent',1,'EventDate DESC','SubscriberKey',_subscriberKey)) == 0
SET @dayssincelastsend = 1
var @dayssincelastsend set @dayssincelastsend = DateDiff(Field(Row(lookuporderedrows('_Sent',1,'EventDate DESC','SubscriberKey',_subscriberKey),1,),'EventDate'),NOW(),'D')
IF @dayssincelastsend == @shortestInterval THEN
RaiseError(Concat('Days since last send: ',@dayssincelastsend),true)
var @dayssinceprevious
IF RowCount(lookuporderedrows('_Sent',2,'EventDate DESC','SubscriberKey',_subscriberKey)) == 0
SET @dayssinceprevious = 8
var @dayssinceprevious set @dayssinceprevious = DateDiff(Field(Row(lookuporderedrows('_Sent',1,'EventDate DESC','SubscriberKey',_subscriberKey),1,),'EventDate'),NOW(),'D')
IF @dayssinceprevious < @shortestPreviousInterval THEN
RaiseError(Concat('Days since previous send: ',@dayssinceprevious),true)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.