diff --git a/src/Pluf/AB/Funnel.php b/src/Pluf/AB/Funnel.php index 8d88085..a0cafeb 100644 --- a/src/Pluf/AB/Funnel.php +++ b/src/Pluf/AB/Funnel.php @@ -56,6 +56,41 @@ class Pluf_AB_Funnel } /** + * Get all the properties for a given period. + */ + public static function getFunnelProps($funnel, $period='today') + { + $db = Pluf_AB::getDb(); + switch ($period) { + case 'yesterday': + $q = array('t' => (int) gmdate('Ymd', time()-86400)); + break; + case 'today': + $q = array('t' => (int) gmdate('Ymd')); + break; + case '7days': + $q = array('t' => array('$gte' => (int) gmdate('Ymd', time()-604800))); + break; + case 'all': + default: + $q = array(); + break; + } + $q['f'] = $funnel; + $props = array(); + foreach ($db->funnellogs->find($q) as $log) { + foreach ($log['p'] as $prop => $v) { + if (isset($props[$prop]) and !in_array($v, $props[$prop])) { + $props[$prop][] = $v; + } else { + $props[$prop] = array($v); + } + } + } + return $props; + } + + /** * Get stats for a given funnel. * * @param $funnel string Funnel diff --git a/src/Pluf/AB/Views.php b/src/Pluf/AB/Views.php index 4450f6b..c7dcf51 100644 --- a/src/Pluf/AB/Views.php +++ b/src/Pluf/AB/Views.php @@ -121,13 +121,20 @@ class Pluf_AB_Views $period = $request->REQUEST['p']; $nperiod = $periods[$request->REQUEST['p']]; } - //'yesterday', ('today'), '7days', 'all' - $stats = Pluf_AB_Funnel::getStats($match[1], $period); + $props = Pluf_AB_Funnel::getFunnelProps($match[1], $period); + $prop = null; + if (isset($request->REQUEST['prop']) and + in_array($request->REQUEST['prop'], array_keys($props))) { + $prop = $request->REQUEST['prop']; + } + $stats = Pluf_AB_Funnel::getStats($match[1], $period, $prop); return Pluf_Shortcuts_RenderToResponse('pluf/ab/funnel.html', array('stats' => $stats, 'funnel' => $match[1], 'nperiod' => $nperiod, 'period' => $period, + 'props' => $props, + 'prop' => $prop, ), $request); } diff --git a/src/Pluf/templates/pluf/ab/base.html b/src/Pluf/templates/pluf/ab/base.html index c08eb05..4feeb00 100644 --- a/src/Pluf/templates/pluf/ab/base.html +++ b/src/Pluf/templates/pluf/ab/base.html @@ -12,15 +12,30 @@ It contains the standard header and footer. body { background: #fff; font-family: Lucida Grande, Verdana, sans-serif; - padding: 1em 2em; - magrin-left: 100px; - width: 600px; } h1, h2 { font-weight: normal; } +#main { + width: 600px; + float: left; + position: relative; + margin: 1em 2em; +} + +body.funnel #main { + width: 900px; +} + +#details { + width: 300px; + float: left; + position: relative; + margin: 1em 2em; +} + hr { border: 1px solid #d3d7cf; border-collapse: collapse; @@ -118,12 +133,20 @@ p.note { margin-top: 5px; } +.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0} +td { + vertical-align: bottom; +} {/literal} -
-{block body}{/block} + +- -Today | -Yesterday | -Last 7 days | -All time +
+ +Today | +Yesterday | +Last 7 days | +All time {assign $i=1} {foreach $stats as $step}{if $step} + {if $i>1}{$step['total']} ({$step['conv']}) - {/if} -Step {$i}: {$step['name']}+Step {$i}: {$step['name']}+ |
+{if $i==1}
+{if count($props)}
+Filter by visitor property+ +{/if} +{elseif isset($step['props'])}{assign $stepprops = $step['props']} +{foreach $stepprops as $k=>$t} +{$k}: {$t} +{/foreach} +{/if} + |
+
-{if $i>1}
+{if $i>1 and isset($step['conv1'])}
{if $step['conv1'] != '100.00%'} |
We do not have statistics for this period.
{/if} - +{*+{$stats|dump} +*} {/block} +{block details} {* +{if count($props)} +