Exclude an email domain from a send

Sending tons of emails to certain email domains can be tricky, even if your sending IP address reputation is good. ┬áIn Salesforce Marketing Cloud, you can utilize an Audience Exclusion Script to isolate domains for special sending treatment — like throttling or sending at a certain time of day.

Here’s an example that utilizes the AMPScript domain() function and the emailaddr personalization string that’s present in every send context.

Email #1 – Exclude emails to comcast.net domains with an exclusion script:

domain(emailaddr) == "comcast.net"

Email #2 – Exclude emails except comcast.net domains with an exclusion script:

domain(emailaddr) != "comcast.net"

Email #2 would be configured with some throttling or be deployed only at a certain time of day.

Code goes here:

This solution will work for sends to Lists, Groups or Data Extensions.

If Exclusion Scripts are not enabled for your User-Initiated or Triggered Send Definitions, SFMC support can enable them for you.

Number Suffixes in AMPScript

Suppose you want to output a day of the month with a proper suffix (e.g. 1st, 13th). There aren’t any formatting functions in AMPScript to do it, but you can do it with a set of if-statements:

Output

1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
12th
13th
14th
15th
16th
17th
18th
19th
20th
21st
22nd
23rd
24th
25th
26th
27th
28th
29th
30th
31st

Once you’re satisfied that it works, you can simply remove the for-loop and un-comment the set @day = Format(Now(),"dd")) line

Reference

Check List Membership on a Landing Page

Suppose you want to see if a Subscribers exists on a List in a Landing Page or Microsite Page in the Salesforce Marketing Cloud? I generally do that with SSJS for various reasons. It’s also possible to do it with AMPScript API functions. Bonus that it’s faster:

For more info:
Landing Pages
Microsites
AttributeValue()
RequestParameter()
Microsite and Landing Page AMPScript Functions
API AMPScript Functions
Using Complex Filter Parts

A case for the MicrositeURL() function

Do you know about the MicrositeURL() AMPScript function? It’s relatively new. It sure is handy if you’re building custom preference centers in Enterprise 2.0 business units.

The idea is that you can encrypt custom parameters in your email links to Microsite pages and then retrieve the unencrypted values with an AMPScript function. Once you have the business unit MID in the microsite page, you can use it to ensure your API calls are for the correct business unit.

In your email you would have this code:

In the case where the the subscriberMID is not set, default to the parent business unit’s MID, which is accessible from the memberid personalization string.

One gotcha: If you build your custom preference centers with Server-Side Javascript, there’s no SSJS function to retrieve the additional MicrositeURL parameters — you to use AMPScript. Your code may end up looking something like this:

For further reading:
MicrositeURL()
RequestParameter()
Personalization Strings
Server-Side JavaScript