I'm having some issues understanding a custom unsubscribe link that links to a 3rd party landing page.

What I would like to do is this:

<a href="%%=RedirectTo(concat('https://example.com/unsubscribe?param1=',_SubscriberKey,'&param2=',Base64Encode(emailaddr, 'UTF-16')))=%%">link</a>

Not a single email using the inline code above arrives, even though I'm not receiving any errors in the rendered subscriber preview and the link shows 100% correct there.

What I have to do to get this link to work is the following:

  var @email, @email64, @unsub, @unsub1, @unsub2 
  set @email = emailaddr 
  set @email64 = Base64Encode(@email, "UTF-16") 

  set @unsub1 = concat("https://example.com/unsubscribe?param1=", _subscriberkey) 
  set @unsub2 = concat("&param2=", @email64) 

  set @unsub = concat(@unsub1, @unsub2) 

<a href="%%=RedirectTo(@unsub)=%%">link</a>

I couldn't find anything in the docs as to why my 1-liner would lead to errors, so I would really appreciate it if anyone could provide some insight in terms of what's happening here.

On a side note: any way to enable a more verbose error handling? Emails simply not showing up isn't really helpful trying to figure out what's happening here.

  • in regards to error handling: you can add a try catch block with ssjs and log possible errors to a DE. curious if anything pops up with this.
    – DonL
    Mar 12 at 16:04
  • thanks @DonL, completely forgot about that. I'll give it a try next week.
    – Tom
    Mar 12 at 16:59
  • 1
    My guess is that the test send email is not sent as there's another issue. For example, you are previewing and test sending with a Subscriber record who has previously unsubscribed, or is blocked by list detective (like a role-based email). I would start with trying another Subscriber record Mar 13 at 3:22
  • Part of my "answer" is - oneliners are definitely harder to debug. I encourage everyone on my team to avoid this "elegant" path for one that's easier to follow and dissect. I. see nothing wrong with a couple rows instead of one. btw, one wild guess is it might have to do with the use of a variable instead of emailaddr personalization string, which is something that structurally sets your two solutions apart. cheers :) Mar 15 at 9:00
  • Thanks for all the input guys, really appreciate it. I wrapped the one-liner in a try-catch SSJS block today and haven't experienced issues with it yet - all test emails arrived (same test subscriber...) and the concat() of all 4 arguments worked as intended. I then removed the SSJS and haven't received any of those emails... In conclusion, both adding SSJS and writing AMPscript within its dedicated block seems to change the way email generation behaves - I'll accept that for now.
    – Tom
    Mar 15 at 9:32

Your Answer

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

Browse other questions tagged or ask your own question.