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

人走茶凉 提交于 2019-12-07 04:11:06

问题


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.


回答1:


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-



来源:https://stackoverflow.com/questions/18063266/how-to-add-params-to-all-links-in-a-mandrill-template-through-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!