Can I send Mailchimp Tags via Form

Can I send Mailchimp Tags via Form? I have fields like Name etc in my form, and additionally I would like to send tags, that I can use in Mailchimp.
Tags are invisible for my user, but i can use them in Mailchimp, eg for segmentation, it's a normal MC-function...

  • Konstantinos Xenos
    • Rubber Duck Debugger

    Hi Achim ,

    You can do the following to support tags if you like for the time being:

    In your form have a Hidden Field and add the values as a comma separated list "tag_one,tag_two" ( if you want multiple ), or single if you want 1 tag only "tag_one".


    Then either in your functions.php ( preferably the child themes ) or in a mu-plugin add this snippet:

    Note: You'll have to replace the "hidden-1" value from $_REQUEST['hidden-1'], into the ID that your hidden field has in the form.

    add_filter(
    	'forminator_addon_mailchimp_api_request_data',
    	function( $request_data, $verb, $path ) {
    
    		$form_id = $_REQUEST['form_id'];
    		$tag     = sanitize_text_field( $_REQUEST['hidden-1'] );
    		$tags    = explode( ',', $tag );
    
    		if ( is_array( $request_data ) ) {
    			if ( empty( $request_data['fields'] ) ) {
    				$request_data['tags'] = $tags;
    			}
    		}
    
    		return $request_data;
    	},
    	15,
    	3
    );

    And the tags should be now working :slight_smile:

    Tell me if you need further help customizing this, or having trouble implementing this solution so I can help you more.

    I've also notified our developers to see if we can have a built-in support for Tags on a future update but I don't have an ETA for that for the time being.

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.