-
Track form events with Google Analytics
The plugin makes it easy for you to interact with the various form events and run a piece of code, like tracking the event with Google Analytics. Say you want to send an event to Google Analytics every time someone used a form to subscribe? You can do that by adding the following snippet to […]
-
Email notifications for forms
By default, you can use Mailchimp to send an email notification for every sign-up. However, there are some drawbacks to this method. We’re in luck though. You can use Mailchimp for WordPress Premium to send out an email notification for every successful form submission. After activating the Premium plugin, your “edit form” page will have […]
-
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 […]
-
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, […]