-
Google Tag Manager tracking
You can use Javascript Events to track form interactions. Use the following code if you are using GTM. Check here for other analytic integrations. If you are using Google Tag Manager you need to create a Custom Event and Tag in your GTM control panel for it to work. In case of the code above […]
-
Make Interest Groupings a required field
If you include an interest grouping in your sign-up form using checkboxes, you may want to enforce your visitors to select at least one interest. There are multiple ways to go about this. As a start, you can pre-select one of the choices. To do this, you can add a “checked” attribute to the input […]
-
JavaScript form events
Mailchimp for WordPress triggers various JavaScript events whenever your visitors interact with a sign-up form on your site. These events can be used to run custom code, for example to track form sign-ups with Google Analytics. You can include this code directly in the form editor if you like. The mc4wp reference is only registered […]
-
Add CAPTCHA to forms
As of version 4.7 of Mailchimp for WordPress it is no longer possible to add Google reCAPTCHA to your forms. Don’t worry though — you probably do not need it anyway. Mailchimp for WordPress comes with built-in spam protection which should stop most bots from using your sign-up methods. If you are actually experiencing spam […]
-
Populate fields with URL data
If you want to populate certain form fields with data from the request URL then you can do this using what we call dynamic content tags. There are various built-in tags available, but the one we’ll need to retrieve data from the URL is {data key="NAME"}. Say you want to send a hidden “source” and […]
-
Add CSS class to form element
You can add or remove CSS classes to the HTML element containing the sign-up form using the mc4wp_form_css_classes filter hook. If we wanted to add a form-inline class to the form, we can use the following code: The above example adds the form-inline class which is used by Bootstrap. Please note that this filter adds […]
-
Show sign-up form from theme files
To show a sign-up form from the PHP files in your WordPress theme, you can use the mc4wp_show_form() function. It takes an optional parameter which defines the ID of the form you would like to show. If you omit this parameter, your default form will be shown. Example: Showing default form Example: Showing form with […]
-
Add custom form validation
It is possible to add custom form validation logic to any form created by the Mailchimp for WordPress plugin using a filter hook. The following snippet will throw an error if a field named some-field does not have the value expected-value. To show a custom message for the incorrect_value error code returned above, you will […]
-
Show sign-up form in sidebar or footer
In most WordPress themes, the sidebar and footer are so called widget areas. This means that you can use the dedicated “Mailchimp for WP Form” widget to show a sign-up form in these areas. To add this widget to your sidebar, go to Appearance > Widgets and select the Mailchimp for WP Form widget. Then, […]
-
Add Mailchimp subscribe form to all posts automatically
To automatically add a sign-up form to all your posts, go and edit the form you would like to show and open up the Settings tab. From there, locate the Automatically add this form to posts in the following category setting and pick a category. Then save the form to update your settings. That will […]