diff --git a/src/Pluf/AB/Funnel.php b/src/Pluf/AB/Funnel.php index a0cafeb..9f54c1d 100644 --- a/src/Pluf/AB/Funnel.php +++ b/src/Pluf/AB/Funnel.php @@ -131,6 +131,9 @@ class Pluf_AB_Funnel if ($prop and !isset($steps[$step]['props'])) { $steps[$step]['props'] = array(); } + if ($prop and !isset($log['p'][$prop])) { + continue; + } $steps[$step]['total'] = (isset($steps[$step]['total'])) ? $steps[$step]['total'] + 1 : 1; if ($prop) { @@ -150,6 +153,18 @@ class Pluf_AB_Funnel $tn = $steps[$i]['total']; $steps[$i]['conv'] = sprintf('%01.2f%%', 100.0 - (float)($tp-$tn)/$tp*100.0); $steps[$i]['conv1'] = sprintf('%01.2f%%', 100.0 - (float)($t1-$tn)/$t1*100.0); + if ($prop) { + $steps[$i]['sprops'] = array(); + foreach ($steps[$i]['props'] as $v => $t) { + $pv = isset($steps[$i-1]['props'][$v]) ? $steps[$i-1]['props'][$v] : 0; + $steps[$i]['sprops'][$v] = array($t, $pv); + if ($pv) { + $steps[$i]['sprops'][$v][] = round(100*(float)$t/(float)$pv,2).'%'; + } else { + $steps[$i]['sprops'][$v][] = 0; + } + } + } } } return $steps; diff --git a/src/Pluf/templates/pluf/ab/funnel.html b/src/Pluf/templates/pluf/ab/funnel.html index 4c644c3..378f8aa 100644 --- a/src/Pluf/templates/pluf/ab/funnel.html +++ b/src/Pluf/templates/pluf/ab/funnel.html @@ -38,9 +38,10 @@ {/if} -{elseif isset($step['props'])}{assign $stepprops = $step['props']} +{elseif isset($step['props'])}{assign $stepprops = $step['sprops']} {foreach $stepprops as $k=>$t} -
{$k}: {$t}
+{$k}
+{$t[0]} out of {$t[1]} visitors{if $t[2]}({$t[2]}){/if}