SOLVED

Creating dynamic, custom external unsubscribe URL with Lead Attributes

Go to solution
Highlighted
Anonymous
Not applicable

Creating dynamic, custom external unsubscribe URL with Lead Attributes

We are building an external subscription preferences page which we will use to update unsubscribe preferences via the Marketo API. In order to do this, we need to know the user that clicked the unsubcribe link.

In our Marketo Email Admin unsubscribe HTML, we are attempting to dynamically generate a link based on the user to our email preferences page. See example:

#set($url = "doman.com/email_preferences/${lead.useId}")

<a href="https://${url}">Manage your Email Preferences</a></p>

Upon clicking the link in the email we get redirected to an invalid url (i.e. https://%24%7Burl%7D/?mkt_tok=xxxx)

How can we dynamically generate an unsubscribe link that contains lead attributes?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 10 - Community Moderator

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

Oh, you're putting it in the Unsubscribe HTML?  That's why it's being escaped. Put the link in the email body itself. You do, however, want {{Lead.Id}}, not {{Lead.UniqueId}}.

As I said above, building a Subscription Manager outside of Marketo using API calls is not recommended because it is immediately a DoS vector.

View solution in original post

5 REPLIES 5
Highlighted
Level 10 - Community Moderator

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

There's no need for Velocity scripting here.  You can just add the {{lead.token}} directly to the link in the Email editor.

I really do not advise creating an unsubscribe page that can only be used 10,000 times a day (and that's before malicious users get ahold of it).  You need to make a good-faith effort to honor unsubscribe requests, and "too many requests came in" isn't an excuse.

Highlighted
Anonymous
Not applicable

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

Hi Sanford. Thanks for the reply! Including the {{lead.uniqueId}} in the href for the Marketo Email Admin unsubscribe HTML textarea (not part of an Email editor) results in a broken link while we've been testing. Marketo replaces the url in the email with one that triggers a redirect on click to the url we made but the lead attribute is not interpolated.

For example:

<a href="https://domain.com/email_preferences/{{lead.uniqueId}}">

Results in a marketo link that redirects to "https://doman.com/email_preferences/%7B%7Blead.uniqueId%7D%7D"

Highlighted
Level 10 - Community Moderator

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

{{Lead.Id}}

Highlighted
Anonymous
Not applicable

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

Hey Sanford,

That didn't do the trick. We're getting the same error. We use lowercase "lead" everywhere else without issue. I suspect we're having problems because we're trying to interpolate attributes in the Email Admin unsubscribe HTML field which seems to act differently than typical fields do.

Highlighted
Level 10 - Community Moderator

Re: Creating dynamic, custom external unsubscribe URL with Lead Attributes

Oh, you're putting it in the Unsubscribe HTML?  That's why it's being escaped. Put the link in the email body itself. You do, however, want {{Lead.Id}}, not {{Lead.UniqueId}}.

As I said above, building a Subscription Manager outside of Marketo using API calls is not recommended because it is immediately a DoS vector.

View solution in original post