Hi there,
I’m looking for a way to add a tag to MailChimp subscriber based on the UTM parameters in the URL.
We’ll have many different sources and instead of using many different forms, we want to use a single form and pass a specific UTM parameter as a tag.
I’m using your yikes-mailchimp-filter-before-submission filter but so far I was only able to push the UTM as a MERGE TAG field, but I can’t use them to trigger automations in MailChimp.
This is the code I have so far and it works for merge tags:
// UTM CAMPAIGN START
add_filter( 'yikes-mailchimp-filter-before-submission', 'add_ucampaign_to_mailchimp_submission', 10, 1 );
function add_ucampaign_to_mailchimp_submission( $mc_form_variables ) {
// Set default utm_campaign
$UCAMPAIGN = '';
// Check URL $_GET vars for utm_campaign
if ( isset( $_GET['utm_campaign'] ) && ! empty( $_GET['utm_campaign'] ) ) {
$UCAMPAIGN = $_GET['utm_campaign'];
}
if ( isset( $mc_form_variables ) && ! empty( $mc_form_variables ) ) {
$mc_form_variables['UCAMPAIGN'] = $UCAMPAIGN;
}
return $mc_form_variables;
}
// UTM CAMPAIGN END// UTM CAMPAIGN START
add_filter( 'yikes-mailchimp-filter-before-submission', 'add_ucampaign_to_mailchimp_submission', 10, 1 );
function add_ucampaign_to_mailchimp_submission( $mc_form_variables ) {
// Set default utm_campaign
$UCAMPAIGN = '';
// Check URL $_GET vars for utm_campaign
if ( isset( $_GET['utm_campaign'] ) && ! empty( $_GET['utm_campaign'] ) ) {
$UCAMPAIGN = $_GET['utm_campaign'];
}
if ( isset( $mc_form_variables ) && ! empty( $mc_form_variables ) ) {
$mc_form_variables['UCAMPAIGN'] = $UCAMPAIGN;
}
return $mc_form_variables;
}
// UTM CAMPAIGN END
I saw in your documentation that you have this filter as well:
yikes-mailchimp-process-default-tag
Would I use that one to add tags and how?
I appreciate your help!
Thanks!