Two-Click Unsubscribe with AMPscript

With additional scrutiny on outbound links in corporate inboxes these days, one-click unsubscribe pages aren’t always a good idea — any visit from a click will result in an immediate action. In the case of a one-click unsubscribe page, it’s an opt-out.  That’s no good.

Here’s an example of a two-click unsubscribe page that requires an additional click to confirm the subscriber’s desire to unsubscribe (or not).

Visit from email

Unsubscribe

Nevermind

The code

As always, if you have any feedback, questions or find any issues with this, feel free to drop me note on the contact page or via comment down below.

My Baby Shark AMPscript Challenge Variations

It’s been a few months since the judging wrapped up for the Baby Shark AMPscript Challenge on HowToSFMC. The goal was to use AMPscript to output the lyrics of Baby Shark (EARWORM WARNING). There were a few of categories for submissions, but I read them all as “with as little code as possible”. Obstinate fixation… engage!

To be completely honest, I spent way too much time obsessing over my own solution — enjoying every moment. Shortest I got on my own was 260 characters. Here are my 7 variations:

1a. 260 characters, compressed

1b. 260 characters, uncompressed

2. Single loop & mod

3. Single loop, mod & math

4. Double loop, string parse

5. String char loop

6. String concatenate loop

7. Multiple concat loop

What I learned

  • The output and outputline functions weirdly require other functions like v or concat.
  • The variable isn’t required for the for-loop next directive
  • I should never, ever write something like this for a client.
  • There are some incredibly talented people in this developer community! I was amazed at some of the entries. The whole thing was super-difficult to judge.

Selecting random data extension rows with AMPscript

In a triggered send scenario, there’s no chance to leverage query activities to prepare auxiliary data for display in an email. I recently had this request from a client:

Display a random set 6 of the products in a specific data extension in the body of this email.

That’s tricky with AMPscript since you can only retrieve ordered rows based on fields and values already in the data extension (e.g you can’t order by GUID(), random() or _customObjectKey with the lookup functions). There are also no arrays or sorting outside of the rowset lookup functions in AMPscript.

Here’s a solution that worked for me:

DataExtensionTest

EmailAddressSubscriberKeyFirstNameLookupKey
doug@limedash.com8473Doug1
suzy@limedash.com5497Suzy1
dale@limedash.com7114Dale1
barb@limedash.com5767Barb1
curt@limedash.com5152Curt1
nora@limedash.com7014Nora1
leon@limedash.com8225Leon1
lily@limedash.com9496Lily1

(NOTE: I added a lookupKey column to my data extension with a default value to facilitate retrieving all of the rows)

Output 1


arr(1): {2}{6}{7}{4}{8}{3}{5}{1}
arr(2): 5497|7014|8225|5767|9496|7114|5152|8473
subscriberkey1: 5497, firstName: Suzy
subscriberkey2: 7014, firstName: Nora
subscriberkey3: 8225, firstName: Leon
subscriberkey4: 5767, firstName: Barb
subscriberkey5: 9496, firstName: Lily
subscriberkey6: 7114, firstName: Dale
subscriberkey7: 5152, firstName: Curt
subscriberkey8: 8473, firstName: Doug

Output2


arr(1): {7}{3}{5}{6}{8}{1}{2}{4}
arr(2): 8225|7114|5152|7014|9496|8473|5497|5767
subscriberkey1: 8225, firstName: Leon
subscriberkey2: 7114, firstName: Dale
subscriberkey3: 5152, firstName: Curt
subscriberkey4: 7014, firstName: Nora
subscriberkey5: 9496, firstName: Lily
subscriberkey6: 8473, firstName: Doug
subscriberkey7: 5497, firstName: Suzy
subscriberkey8: 5767, firstName: Barb

I’m sure there are other ways of approaching this. Know of a simpler way or an alternate approach? Please share!

Reference