forked from aliasaria/PHP-redis-A-B-Testing
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
55 lines (43 loc) · 1.27 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once("core.php");
//we hard code the parcipant ID in this example
$participant_id = "1017";
//you can provide it in the URL:
if (isset($_GET['uid']))
$participant_id = $_GET['uid'];
//STEP 1: SET THE PARTICIPANT ID
ab_init($participant_id, false);
// implement logic based on submission status
if (isset($_POST['submit_action']))
{
ab_track("conversion");
echo "<br><br>Success: Conversion Tracked!";
exit;
}
//STEP 2: DO THE TEST BY CALLING ab_test(..)
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Checkout Button Color Test</title>
</head>
<body>
<form method="post">
<p>
Hello User #<?php echo $participant_id; ?>,
<br />Please press the button if you like its color.
</p>
<?php
$size = ab_test('checkout_button_size');
$font_size = "12pt";
if ($size == "small")
$font_size = "9pt";
elseif ($size == "medium")
$font_size = "12pt";
else //if $size = "large"
$font_size = "20pt";
?>
<input type="submit" name="submit_action" value="Submit With This Color" style="background-color: <?php echo ab_test('checkout_button_color') ?>; font-size: <?php echo $font_size?>;" />
</form>
</body>
</html>