问题
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¶m2=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.
回答1:
Sure, you can use merge tags to do this. Your link would look something like this:
<a href="http://google.com?param1=*|PARAM1|*¶m2=*|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-
来源:https://stackoverflow.com/questions/18063266/how-to-add-params-to-all-links-in-a-mandrill-template-through-api