function ab_test_conversion_rate($test, $alt) { $p = (int) ab_tests_total_participants_for_alternative($test, $alt); //$c1 = (int)ab_tests_total_conversions_for_alternative($test,$alt); $c2 = (int) ab_tests_total_converted_for_alternative($test, $alt); if ($p > 0) { $conv_rate = $c2 / $p * 100; } else { $conv_rate = 0; } return $conv_rate; }
//echo "<P class=\"indent\" style='color: #999; font-size: 15px; margin-top: 12px'>" . "Currently forced to show option <u style='color: #666'>$forced_alternative</u> for all participants"; /*echo ' <a href="?force=true&test=' . $test['name'] . '&alt=' . "!!null!!" . '" class="red-button pcb"> <span style="color: black;">Clear</span> </a>'; */ } $j = 0; $a = array(); $total_converted = 0; $total_conversions = 0; $total_particants = 0; $array_of_conversion_rates = array(); echo "<div class=\"alternatives\">"; foreach ($alternatives as $alt) { $p = $a[$alt]['participants'] = (int) ab_tests_total_participants_for_alternative($name, $alt); $c1 = $a[$alt]['conversions'] = (int) ab_tests_total_conversions_for_alternative($name, $alt); $c2 = $a[$alt]['converted'] = (int) ab_tests_total_converted_for_alternative($name, $alt); if ($p > 0) { $conv_rate = $c2 / $p * 100; } else { $conv_rate = 0; } $conv_rate = round($conv_rate, 3); $array_of_conversion_rates[] = array($j + 1, $conv_rate); echo "<h3>Alternative <span class=\"alternative\">" . $alt . "</span>:"; if ($forced_alternative != $alt) { echo ' <a href="?force=true&test=' . urlencode($test['name']) . '&alt=' . urlencode($alt) . '#' . urlencode($name) . '" class="grey-button pcb"> <span style="color: #666;">Show Always</span> </a>'; } else { echo ' <span class="forced-text">Always Showing</span> <a href="?force=true&test=' . urlencode($test['name']) . '&alt=' . "!!null!!" . '#' . urlencode($name) . '" class="red-disabled-button pcb"> <span style="color: #333;">Clear</a>