سؤال

Is it possible to use nested merge tags?

What we need is to be able to define the UNSUB tag depending on the values from other merge tags, like on this example:

<a 
href="*|UNSUB:*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all|*">
Unsubscribe
</a>

Is this correct? Should be done in a different way?

هل كانت مفيدة؟

المحلول

It's not currently possible to nest merge tags. In this case, your best bet would be to add your own List-Unsubscribe headers (using the headers parameter in the API) and pass either your own URL, or a URL constructed with your merge tags but not the UNSUB merge tag.

نصائح أخرى

From the API:

What happens when the [unsubscribe] link is clicked?

If a recipient clicks the generated link, the message status is changed to Unsubscribed and > the recipient's address is added to the Rejection Blacklist in your Mandrill account. The redirect URL will be appended to include two querystring parameters that can be used for processing the unsubscribe in your own system or database:
md_id - the _id, as provided in the API call and webhooks of the specific message where the unsubscribe link was clicked
md_email - a URL-encoded version of the recipient's email address

So you don't have to worry about generating an unsubscribe url for every user. Just put a generic url and mandrill automatically will append to you the email of that user in the md_email variable.

The documentation suggest that you do this then:

<a href="*|UNSUB:http://mywebsite.com/unsub|*">Click here to unsubscribe.</a>

And mandrill will append the correct user email and id:

 http://mywebsite.com/unsub?md_email=fulanito@gmail.com&m_id=23321

Since mandrill doesn't support nested merge tags, here is the solution for the case like yours if you dont mind after user click unsub, it did't go to mandrill's black list, since the unsubsription are all handled by your app.

PER YOUR CASE:

  1. Manually compose your unsubscribe link e.g. *|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/
  2. At the end of your link, append the mandrill recipient email var.email=*|EMAIL|* e.g. *|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/?email=*|EMAIL|*
  3. Put the link to your mandrill template

    <a href="*|COMMUNITYURL|*/site/unsuscribe/user_id/*|USERID|*/hash/*|HASH|*/type/all/?email=*|EMAIL|*">Unsubscribe Me</a>

reference: mandrill doc

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top