Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mandrill - The difference between global_merge_vars and normal merge_vars

I've looked at this Mandrill knowledgebase article over and over and cannot see any obvious explanation of what the difference is between Global Merge Vars and Merge Vars, and when I should use global vs normal.

Both global_merge_vars and merge_vars are declared within the 'message' object (as shown here in the Mandrill API), so it's not like you're declaring global_merge_vars outside the message object and then including multiple merge_vars.

Also - is there any difference between how these are declared in the template itself or do they all just use *|MERGE_VAR_NAME|* format?

like image 375
alexleonard Avatar asked May 10 '13 08:05

alexleonard


2 Answers

The global_merge_vars parameter allows you to pass global values for a particular merge tag, to be applied for all recipients in that API call by default, while merge_vars allows you to specify per-recipient values based on the recipient email address (this is why the rcpt is declared for merge_vars). The content in the email or template doesn't vary - these API parameters are just distinct since they apply differently.

The template_content parameter is for editable regions in the template. More details here. Originally, Mandrill didn't support merge tags, and only supported editable regions in templates. For backwards-compatibility, template_content is still required when calling a template. It also helps to ensure that even if a template region isn't to be replaced, that's done explicitly by passing a blank array.

The Mandrill KB has quite a bit of info on various topics, and you can submit a support request there if you have questions specific to your account, or in general!

like image 81
Kaitlin Avatar answered Oct 15 '22 11:10

Kaitlin


global_merge_vars: Give global or default values for merge tags by using the global_merge_vars parameter. These will be used in the case where a recipient doesn't have a recipient-specific value defined.

merge_vars: Use the merge_vars parameter to store recipient-specific values if sending to more than one recipient at a time.

like image 1
Mritunjay Upadhyay Avatar answered Oct 15 '22 10:10

Mritunjay Upadhyay