diff --git a/src/Pluf/AB/Funnel.php b/src/Pluf/AB/Funnel.php index 4a554fd..8d88085 100644 --- a/src/Pluf/AB/Funnel.php +++ b/src/Pluf/AB/Funnel.php @@ -71,7 +71,7 @@ class Pluf_AB_Funnel } switch ($period) { case 'yesterday': - $q = array('t' => array('$eq' => (int) gmdate('Ymd', time()-86400))); + $q = array('t' => (int) gmdate('Ymd', time()-86400)); break; case 'today': $q = array('t' => (int) gmdate('Ymd')); @@ -105,6 +105,9 @@ class Pluf_AB_Funnel } } // Now, compile the stats for steps 2 to n + if (!isset($steps[1]['total'])) { + return array(); + } $t1 = $steps[1]['total']; for ($i=2;$i<=20;$i++) { if ($steps[$i] and $steps[$i-1]) { diff --git a/src/Pluf/AB/Views.php b/src/Pluf/AB/Views.php index 5b6a392..4450f6b 100644 --- a/src/Pluf/AB/Views.php +++ b/src/Pluf/AB/Views.php @@ -110,10 +110,24 @@ class Pluf_AB_Views 'Pluf_AB.view-funnels')); public function funnel($request, $match) { - $stats = Pluf_AB_Funnel::getStats($match[1]); + $periods = array('yesterday' => __('Yesterday'), + 'today' => __('Today'), + '7days' => __('Last 7 days'), + 'all' => __('All time')); + $period = 'today'; + $nperiod = $periods[$period]; + if (isset($request->REQUEST['p']) + and isset($periods[$request->REQUEST['p']])) { + $period = $request->REQUEST['p']; + $nperiod = $periods[$request->REQUEST['p']]; + } + //'yesterday', ('today'), '7days', 'all' + $stats = Pluf_AB_Funnel::getStats($match[1], $period); return Pluf_Shortcuts_RenderToResponse('pluf/ab/funnel.html', array('stats' => $stats, 'funnel' => $match[1], + 'nperiod' => $nperiod, + 'period' => $period, ), $request); } diff --git a/src/Pluf/templates/pluf/ab/base.html b/src/Pluf/templates/pluf/ab/base.html index e068581..c08eb05 100644 --- a/src/Pluf/templates/pluf/ab/base.html +++ b/src/Pluf/templates/pluf/ab/base.html @@ -62,6 +62,10 @@ pre { padding: 0; } +.strong { + font-weight: bold; +} + .note, .details { font-size: 0.8em; } diff --git a/src/Pluf/templates/pluf/ab/funnel.html b/src/Pluf/templates/pluf/ab/funnel.html index 52e13f9..5b15b75 100644 --- a/src/Pluf/templates/pluf/ab/funnel.html +++ b/src/Pluf/templates/pluf/ab/funnel.html @@ -3,7 +3,18 @@ {block body}

» All funnels

-

Funnel {$funnel}

+

Funnel {$funnel} - {$nperiod}

+ +

+ +Today | +Yesterday | +Last 7 days | +All time + +

+ + {assign $i=1} {foreach $stats as $step}{if $step} {if $i>1} @@ -24,7 +35,7 @@

{assign $i += 1} {/if}{/foreach} - +{if count($stats)}
{assign $i = $i-1} @@ -35,7 +46,9 @@ This is a completion rate of {$stats[$i]['conv1']}.

Note that if a user skip a given step, this can make the results a bit off.

- +{else} +

We do not have statistics for this period.

+{/if} {/block}