A/B testing forms with gravity forms

A/B Testing Forms using Gravity Forms

A/B testing of landing pages, sometimes referred to as split testing, is one of the many strategies we use to optimize landing pages for conversions. In short, we create two (or more) versions of a specific page and drive equal amounts of traffic to these pages. The landing page with the best conversion rate – email signups, donations, petition signing, form completions – is the winner.

A/B testing forms

We have recently been using Gravity Forms — one of the best form builders out there — and thought it would be helpful to share some information about implementing A/B tests using these forms.

How to Setup A/B Testing Forms on your Landing Pages

What we’re trying to achieve here is the ability to use different forms and messaging on the forms to see which one generates a better conversion rate for our users. For example, do users tend to fill out a quick form that just asks for their name and email address or do they not mind filling one out that asks for more information like gender, and location as well? In order to do this, you will have to create multiple forms in Gravity Forms and each form will have its own variation. Once you are done, follow the steps below.

You have two options:

Option A:

Install the plugin we created and made available on the WordPress plugin repository.

Option B:

Add the following code to your theme’s functions.php file

add_shortcode('gravity_form_ab', 'gravity_ab');

function gravity_ab($atts){
	$a = shortcode_atts( array(
		'ids' => '',
		'title' => 'false',
		'description' => 'false',
		'ajax' => 'false'
	), $atts);

	$ids = explode(",", $a['ids']);
	$count = count($ids) - 1;
	if($count > 0){
		$rand = mt_rand(0,$count);
		return do_shortcode('[gravityform id="'. $ids[$rand].'" title="'. $a['title']. '" description="'. $a['description'] .'" ajax="'. $a['ajax'] .'"]');

You would then use the following shortcode:

[gravity_form_ab ids="1,2,3" title="false" description="false" ajax="false"]

Commas separate the different gravity form ids in the ids parameter. The title, description and ajax parameters are false by default and are optional.

What’s happening in the back end of the site is, the code is using a randomizer to determine which gravity form is shown and depending on how many gravity form IDs you’ve used, the probability of it being shown to a user differs.

Questions? Comments? Leave a note in the comments below or reach out to us at connect@mediacause.org. Follow us on Facebook and Twitter for more nonprofit marketing tips, and sign up for our newsletter for a monthly update from our nonprofit marketing pros!


Related Posts