6

I need to add some params to all links from a Mandrill template before sending. For example, in the template there are anchors like <a href="http://google.com>click here</a>".

What I need is to add a string (set of params to every anchor), like this: <a href="http://google.com?param1=value1&param2=value2>click here</a>", dynamically

Is there a way to do it through the API? Something similar to X-MC-GoogleAnalyticsCampaign which adds the utm_campaign param.

Alexandru R
  • 8,560
  • 16
  • 64
  • 98

1 Answers1

6

Sure, you can use merge tags to do this. Your link would look something like this:

<a href="http://google.com?param1=*|PARAM1|*&param2=*|PARAM2|*">click here</a>

You'd then want to pass the values for PARAM1 and PARAM2 in the SMTP headers, or in your API call.

For SMTP, you'd use the X-MC-MergeVars header. Here's more information on that specific header: http://help.mandrill.com/entries/21688056-Using-SMTP-Headers-to-customize-your-messages#mergetags

If you're using the API (messages/send or messages/send-template), you'd want to use the merge_vars or global_merge_vars parameters to set the values for PARAM1 and PARAM2 (merge_vars is for recipient-specific info, while global_merge_vars is for all recipients in that API call).

General overview on using merge tags to create dynamic content with Mandrill: http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content-

Kaitlin
  • 6,167
  • 32
  • 30
  • 5
    I'm doing the merge_vars thing with the links as a whole (entire links are in the tags) and I'm losing click tracking. Mandrill doesn't interpret links anymore. Any solution to this?... something like an API call to force it reparse the template before sending? – Alexandru R Aug 10 '13 at 03:40
  • Can I pass this full website in this variable ? – ephemeral Aug 08 '17 at 09:10