This page may contain affiliate links. Please read my disclaimer for more information.

Gravity Forms A/B Split Testing

  |  by Chris Eggleston

Problem

We recently received an interesting request from a Gravity Forms user who wanted to know how to do A/B split testing in Gravity Forms.

More specifically, they wanted to test the results for a webinar reply/sales page, so after the user had already signed up for the webinar.

They were testing things like auto-play on the video versus user controls. And they wanted to test the buy button text and call to action. On this site, everything from the opt-in to the checkout was handled by Gravity Forms.

The Challenge

Knowing Gravity Forms does not have any built-in features for this we first looked to plugins like A/B Split Test, but it didn’t seem to offer any integration with form builders. I also found this cool solution from Gravity Wiz for split testing forms, but it didn’t provide what we needed.

Then in thinking about the problem, I figured we could just use different confirmation redirects, but how do we randomly choose which one to show to which user, and how do we track it?

Solution

Before we jump into the solution, let’s outline the problem we need to solve.

  1. Randomly choose users to be shown a different confirmation page
  2. Determine how the correct confirmation page is displayed
  3. Track which user sees what page and their conversion
  4. Do all of this in Gravity Forms

When I have a problem like this, I am always interested in the shortest path, which usually means leveraging what I already have.

In this case, we already have:

  1. Conditional logic
  2. Ability to create multiple confirmations
  3. Entry data

1. Randomly choose users to be shown a different confirmation page

This was the only step that required some custom functionality.

For this, we created a simple script to randomly assign A or B to each submission.

// AB Test for webinar page
add_action('gform_pre_submission_33', 'assign_random_ab_variant'); 
    function assign_random_ab_variant($form) { // Randomly assign "A" or "B" to the hidden field
     $_POST['input_5'] = (rand(0, 1) == 0) ? 'A' : 'B'; // Replace Y with your hidden field ID 
}

This runs before the form (ID 33) is submitted, randomly chooses either ‘A’ or ‘B’, and assigns that value to a hidden field (input_5) in the form before submission.

This code should be placed in your themes functions.php file or in a code snippet plugin like WPCodeBox (my favorite).

2. Determine how the correct confirmation page is displayed

In this use case, we were only testing against two different reply pages that also had the offer and buy buttons. Which meant we only need to create two different confirmation redirects.

Once we had the reply pages built and the confirmation set up we simply had to set the conditional logic for the confirmations to show one when the hidden field was populated with A and the other when the field was populated with B.

3. Track which user sees what page and their conversion

Since we’re capturing the results in a hidden field, we’re able to see what page the user was sent to that led to the conversion.

To take this a step further, since the opt-in form and checkout form are different, I used a query string in the buy buttons that included the A or B and dynamic population in the checkout page so that we could capture that data in a hidden field within the checkout form.

4. Do all of this in Gravity Forms

Except for the custom code, we were able to do all of this with built-in Gravity Forms functionality. Now this is a very simple solution and does not offer any type of reporting or conversion ratings, but you will at least have the data to determine which page is converting the best.

The Wrap Up

If you’re looking for a simple way Gravity Forms A/B Split Test solution this might work. There are several different usages you could come up with and I’ve outlined a couple below.

If you’re looking for an advanced solution with data and stats this probably isn’t it, but it could be a start to something better.

Also if you’re interested in doing a split test against two different forms, check this solution from Gravity Wiz: Simple Split Testing with Gravity Forms

Other Possible Uses

There are other ways you could use the Gravity Forms A/B split testing solution that would still fall within the scope of this code and Gravity Forms functionality.

Example 1:

They say that forms with fewer fields convert better, but what if you could test that? With this code, you could.

If you want to know if your form converts better without a phone field, simply apply conditional logic to the phone field to only show when the hidden field is populated with A.

Anyone who is assigned B will not see the phone field and thus you can see if there is a conversion impact with fewer fields.

Example 2:

What if you want to assign newsletter opt-ins to different email campaigns for conversion testing?

Just like with the confirmation conditional logic, you can integrate with one of the email platforms (i.e. Mailchimp, ActiveCampaign, etc) and use multiple feeds with conditional logic to determine which list the user is added to based on the A or B assigned to the form for that user.

Need More Help?

If you still need help, feel free to use the comments or chat options below, you can even try our contact form here. If you need a more custom approach you can reach out to my WP Mantis for help building your solution.

Photo of author
About the Author
Chris Eggleston
Husband to 1. Father to 4. Grandpa to 1. Gravity Forms enthusiast. As the owner of WP Mantis, I’m on a mission to simplify the WordPress experience for site owners. I try to bring a unique perspective to the Gravity Forms community.

Support Chris - Donate $5

Gravity Wiz Add-Ons

Advertisement

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments