How to Send the Entry ID to Mailchimp

Introduction

Would you like to send the entry ID to Mailchimp? It’s an easy way to track and find specific users that sign up for your newsletter by simply searching for the entry ID number. In this tutorial, we’ll walk you through each step on how to send this ID number to Mailchimp when users complete your forms.

Creating the custom field in Mailchimp

First, you’ll want to create a custom field in Mailchimp that will store this ID number. To do this, you can follow along with the steps in their guide.

For our form, we created a form inside Mailchimp that has the First Name, Last Name, Email Address, and a simple Text field.

The Settings for this field will have the Field Label as Entry ID and the Field Tag as ENTRY_ID.

Once you’ve saved the field to your form, your All Contacts page will show the column for this field. This is where we will store the entry ID when the form is submitted.

add your custom field to your mailchimp form

Creating the form

Now it’s time to create your form. For our form, we’re only going to have the First Name, Last Name, and Email Address.

If you need help in creating your form, please see this tutorial.

create your form with your desired fields

Connecting your form to Mailchimp

Now it’s time to connect your site to Mailchimp on the Marketing tab of the form builder.

For assistance with this, please see this documentation.

Once you’ve set up your connection and mapped your fields over you are ready for the next step!

make your form connection to Mailchimp through the Marketing tab inside the form builder

Adding the code to send the entry ID to Mailchimp

Now it’s time to add the snippet that will send through this ID when the form is processed and the subscriber is added to the Mailchimp list.

If you need help in adding code snippets to your site, please see this tutorial.

/** Send through entry ID from WPForms to Mailchimp
 *
 *  @link   https://wpforms.com/developers/how-to-send-the-entry-id-through-to-mailchimp/
**/

function wpf_dev_mailchimp_provider_process_action_subscribe_request_data( $data, $fields, $form_data, $entry_id ) {
	
    if ( empty( $entry_id ) ) {
      return $data;
    }

    // Change 'ENTRY_ID' to match the custom field you've created inside Mailchimp. See this doc for more details
    $data[ 'merge_fields' ][ 'ENTRY_ID' ] = absint( $entry_id );
	
    return $data;
	
}

add_action( 'wpforms_mailchimp_provider_process_action_subscribe_request_data', 'wpf_dev_mailchimp_provider_process_action_subscribe_request_data', 10, 4 );

If you didn’t name your custom field ENTRY_ID as instructed above, be sure to update this code snippet to match the name inside this line $data[‘merge_fields’][‘ENTER_CUSTOM_FIELD_NAME_HERE’]

Now when users complete your form and you view the subscriber, you’ll see the entry ID number in the contacts list.

now the entry id will be passed to mailchimp

Would you like to create a Smart Tag for a unique ID so that you can use it in other areas of your form? Take a look at our article on How to Create a Unique ID for Each Form Entry.