-
Notifications
You must be signed in to change notification settings - Fork 66
Custom Merge Tags
khungate edited this page Jul 25, 2023
·
5 revisions
Welcome to the guide on using Custom Merge Tags in the MailChimp for WooCommerce Integration. This guide will help you understand how to add a custom merge tag into Mailchimp by extending our plugin's capabilities.
Custom merge tags allow you to add dynamic data to your Mailchimp Audience. You can add as many merge tags as your list is configured to use. This guide provides an example of how to add a custom merge tag for a user's birthday.
Here's an example of how to add a custom merge tag for a user's birthday:
function custom_user_merge_tags($merge_vars, $user) {
// the date format needs to MATCH the Mailchimp date format otherwise it will fail.
$mailchimp_date_format = "m/d";
// this is an imaginary filter, but let's assume that it returns a date like "2019-09-16"
//$user_birthday = apply_filters('get_user_birthday', $user);
// assign the correct merge tag name, yours may be different.
//$merge_vars['BDAY'] = date($mailchimp_date_format, strtotime($user_birthday));
// return the merge tag array to be submitted.
return $merge_vars;
}
add_filter('mailchimp_sync_user_mergetags', 'custom_user_merge_tags', 100, 2);
Please note that get_user_birthday
is not a real filter, but is meant to show you a quick example of how to add dynamic data to your Mailchimp Audience.