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 “campaign” field to Mailchimp for which the data is in the URL of the page your form is on. To fill the fields with these values, use {data key="source"} and {data key="campaign"} as your field values.

Example form mark-up

	<label for="mc4wp_email">Email address: </label>
	<input type="email" id="mc4wp_email" name="EMAIL" placeholder="Your email address" required />

	<input type="submit" value="Sign up" />

<!-- Notice the value="{data key="xxx"}" attributes of the following fields -->
<input type="hidden" name="source" value="{data key="source"}" />
<input type="hidden" name="campaign" value="{data key="campaign"}" />

The plugin will automatically try and find a “source” and “campaign” field in the URL. If the fields are not present, the plugin will replace the placeholders with an empty string.

Setting default values

You can set a default value for when the specified data is not found by adding a default attribute to the tag.


{data key="NAME" default="Some value"}