Mandrill - The difference between global_merge_vars and normal merge_vars

alexleonard picture alexleonard · May 10, 2013 · Viewed 11.4k times · Source

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?

Answer

Kaitlin picture Kaitlin · May 10, 2013

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!