Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add params to all links in a mandrill template through API?

Tags:

mandrill

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.

like image 442
Alexandru R Avatar asked Aug 05 '13 16:08

Alexandru R


1 Answers

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-

like image 93
Kaitlin Avatar answered Nov 07 '22 19:11

Kaitlin