• Resolved 9stepsemail

    (@9stepsemail)


    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!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter 9stepsemail

    (@9stepsemail)

    Hello,

    May I follow up on this, please?

    Would really appreciate your help with this one.

    Thank you!

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    ?????? YIKES, Inc. Co-Owner

    Hi @9stepsemail

    I am very sorry but have recently lost our plugin support person.

    We will get back to you as soon as we have someone who can assist with this issue.

    Thank you.
    -Tracy

    Hi @9stepsemail,

    I’m not sure I fully understand what you are trying to do, but adding tags can be done using the filter you are already using. You would add the value to the array property ‘tags’.

    Something like $mc_form_variables['tags'][] = $_GET['utm_campaign']; should work.

    Please let me know if that addresses your problem!

    Thanks,
    Jon

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    ?????? YIKES, Inc. Co-Owner

    Hello @9stepsemail,

    Just checking in.

    Please let us know if you still need help with this issue.

    Thank you!
    -Tracy

    Thread Starter 9stepsemail

    (@9stepsemail)

    Hi @liljimmi and @jpowersdev

    I’m not sure how I should apply what you’re suggesting.

    Could you tell me if this is what you’re referring to?

    // 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 ) {
    
    	// Check URL $_GET vars for utm_campaign
    	if ( isset( $_GET['utm_campaign'] ) && ! empty( $_GET['utm_campaign'] ) ) {
    		$mc_form_variables['tags'][] = $_GET['utm_campaign'];
    	}
    	return $mc_form_variables;
    }
    
    // UTM CAMPAIGN END

    Hi @9stepsemail,

    Yes, that looks correct. That code will add the value of $_GET['utm_campaign'] to the list of tags. You should then be able to see and use that tag on your Mailchimp dashboard.

    Jon

    Thread Starter 9stepsemail

    (@9stepsemail)

    Thanks @jpowersdev

    It doesn’t seem to be working. The form shows me this error when I try to subscribe:

    The resource submitted could not be validated. For field-specific details, see the ‘errors’ array.
    Error with field: Data did not match any of the schemas described in anyOf.

    Do I need to add all the tags to that form or none?

    • This reply was modified 4 years, 3 months ago by 9stepsemail.

    Hi @9stepsemail,

    That error looks to be the response you are getting from the Mailchimp server.

    Unfortunately, since this is not functionality included in our plugin, I’m not really able to provide support. I’m just speculating based on what I see here: https://mailchimp.com/developer/api/marketing/list-members/add-member-to-list/

    It’s possible that the tags need to be created before you add them to a member.

    Jon

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add a tag based on UTM parameters’ is closed to new replies.