-
-
Save freezvd/29776909bc3efe1aeb7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create a split test using two different GravityForms | |
* | |
* Allows you to test the effectiveness of two different forms by displaying each | |
* one 50% of the time. Tracking CTR using the built-in GravityForms functionality | |
* should give you an idea of which form is most effective. | |
* | |
* @uses GravityForms | |
* @author FAT Media, LLC | |
*/ | |
function prefix_setup_gform_test( $id_1, $id_2 ) { | |
// Do nothing if we have no forms. | |
if ( ! $id_1 || ! $id_2 ) { | |
return; | |
} | |
// Choose each form 50% of the time. | |
$gform_id = mt_rand(0, 1) ? $id_1 : $id_2; | |
// Display Subscribe Form | |
$gravity_form = do_shortcode( '[gravityform id="' . $gform_id . '" description="false"]' ); | |
return $gravity_form; | |
} | |
// Display the forms. | |
echo prefix_setup_gform_test( 1, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment