diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-31 10:33:52 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-31 10:33:52 +0400 |
commit | dea3812ebf5bb76d9559029060e6fe8b36e2b236 (patch) | |
tree | 3cd700cc75f1df602d7f27b271229aa725bf53b3 /plugins | |
parent | 66ceca7ed6e81e7b9742d79fe6c7c2b6cae8cf87 (diff) |
Refs #898
* Adding new icons to switch between Ecommerce orders/Carts below the table reports "Top Product Sku/name/category"
* Adding column "Ecommerce conversion rate" like other goals, when clicking on "Goal icon" on any report outside of "Ecommerce & Goals" section
* Confirmed that "Revenue per visit" always includes "Ecommerce revenue" as well (but not "Abandoned Cart revenue" since it is not revenue but "potential revenue/loss"
* Ecommerce Order logs renamed to Ecommerce Log, which now shows Orders & Abandoned Carts logs as well
*
git-svn-id: http://dev.piwik.org/svn/trunk@4845 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CoreHome/templates/datatable.css | 8 | ||||
-rw-r--r-- | plugins/CoreHome/templates/datatable.js | 2 | ||||
-rw-r--r-- | plugins/CoreHome/templates/datatable_footer.tpl | 5 | ||||
-rw-r--r-- | plugins/Goals/Controller.php | 88 | ||||
-rw-r--r-- | plugins/Goals/Goals.php | 3 | ||||
-rw-r--r-- | plugins/Goals/templates/table_by_dimension.tpl | 4 | ||||
-rw-r--r-- | plugins/Live/templates/visitorLog.tpl | 6 |
7 files changed, 82 insertions, 34 deletions
diff --git a/plugins/CoreHome/templates/datatable.css b/plugins/CoreHome/templates/datatable.css index e15391eb76..b3488d14ab 100644 --- a/plugins/CoreHome/templates/datatable.css +++ b/plugins/CoreHome/templates/datatable.css @@ -335,7 +335,6 @@ table thead div { .dataTableFooterIcons { display:block; height: 20px; - overflow:hidden; white-space:nowrap; font-size:10px; padding:6px 5px; @@ -384,6 +383,13 @@ table thead div { float:left; padding-right:4px; } +.tableIconsGroup .tableIcon span { + margin-right:5px; + margin-left:5px; +} +.tableIconsGroup img{ + vertical-align:bottom; +} .tableIconsGroupActive{ display:block; diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js index b8ea2c6a01..9396e01714 100644 --- a/plugins/CoreHome/templates/datatable.js +++ b/plugins/CoreHome/templates/datatable.js @@ -579,7 +579,7 @@ dataTable.prototype = } ); - + // Initialize arrow footer to correct icon $('.dataTableFooterWrap a.tableIcon', domElem).each(function(){ if(self.jsViewDataTable==$(this).attr('var')) self.setActiveIcon(this, domElem); }); diff --git a/plugins/CoreHome/templates/datatable_footer.tpl b/plugins/CoreHome/templates/datatable_footer.tpl index 67a8e82c5e..c41cd8c8eb 100644 --- a/plugins/CoreHome/templates/datatable_footer.tpl +++ b/plugins/CoreHome/templates/datatable_footer.tpl @@ -36,9 +36,12 @@ {if $properties.show_goals} <a class="tableIcon" format="tableGoals" var="tableGoals"><img title="{'General_DisplayTableWithGoalMetrics'|translate}" src="themes/default/images/{if $javascriptVariablesToSet.filter_only_display_idgoal=='ecommerceOrder'}ecommerceOrder.gif{else}goal.png{/if}" /></a> {/if} + {if $properties.show_ecommerce} + <a class="tableIcon" format="ecommerceOrder" var="ecommerceOrder"><img title="{'General_EcommerceOrders'|translate}" src="themes/default/images/ecommerceOrder.gif" /> <span>{'General_EcommerceOrders'|translate}</span></a> + <a class="tableIcon" format="ecommerceAbandonedCart" var="ecommerceAbandonedCart"><img title="{'General_AbandonedCarts'|translate}" src="themes/default/images/ecommerceAbandonedCart.gif" /> <span>{'General_AbandonedCarts'|translate}</span></a> + {/if} </span> </div> - {if $properties.show_all_views_icons} <div class="tableIconsGroup"> <span class="tableGraphViews tableGraphCollapsed"> diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index a0f23cf001..2e758e04fb 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -76,45 +76,65 @@ class Piwik_Goals_Controller extends Piwik_Controller echo $view->render(); } - protected function getItemsView($fetch, $type, $function, $api) + protected function getItemsView($fetch, $type, $function, $api, $abandonedCart = false) { + $saveGET = $_GET; $label = Piwik_Translate($type); - $view = Piwik_ViewDataTable::factory(); + $abandonedCart = Piwik_Common::getRequestVar('viewDataTable', 'ecommerceOrder', 'string') == 'ecommerceAbandonedCart'; + + // Products in Ecommerce Orders + if($abandonedCart === false) + { + $view = new Piwik_ViewDataTable_HtmlTable_EcommerceOrder(); + $columns = Piwik_Goals::getProductReportColumns(); + $view->setMetricDocumentation('revenue', Piwik_Translate('Goals_ColumnRevenueDocumentation', Piwik_Translate('Goals_DocumentationRevenueGeneratedByProductSales'))); + $view->setMetricDocumentation('quantity', Piwik_Translate('Goals_ColumnQuantityDocumentation', $label)); + $view->setMetricDocumentation('orders', Piwik_Translate('Goals_ColumnOrdersDocumentation', $label)); + $view->setMetricDocumentation('avg_price', Piwik_Translate('Goals_ColumnAveragePriceDocumentation', $label)); + $view->setMetricDocumentation('avg_quantity', Piwik_Translate('Goals_ColumnAverageQuantityDocumentation', $label)); + $view->setMetricDocumentation('nb_visits', Piwik_Translate('Goals_ColumnVisitsProductDocumentation', $label)); + $view->setMetricDocumentation('conversion_rate', Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label)); + } + // Products in Abandoned Carts + else + { + $view = new Piwik_ViewDataTable_HtmlTable_EcommerceAbandonedCart(); + $columns = Piwik_Goals::getProductReportColumns(); + $columns['abandoned_carts'] = Piwik_Translate('General_AbandonedCarts'); + $columns['revenue'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_ProductRevenue')); + $columns['quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_Quantity')); + $columns['avg_quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_AverageQuantity')); + unset($columns['orders']); + unset($columns['nb_visits']); + unset($columns['conversion_rate']); + $_GET['abandonedCarts'] = 1; + } + $view->init( $this->pluginName, $function, $api ); + $view->enableShowEcommerce(); + $view->disableShowAllViewsIcons(); + $view->disableShowTable(); $view->disableExcludeLowPopulation(); $view->disableShowAllColumns(); $this->setPeriodVariablesView($view); $view->setLimit( 10 ); + $view->setColumnsTranslations(array_merge( array('label' => $label), - Piwik_Goals::getProductReportColumns() - )); - $view->setColumnsToDisplay(array( - 'label', - 'revenue', - 'quantity', - 'orders', - 'avg_price', - 'avg_quantity', - 'nb_visits', - 'conversion_rate', + $columns )); - $view->setMetricDocumentation('revenue', Piwik_Translate('Goals_ColumnRevenueDocumentation', Piwik_Translate('Goals_DocumentationRevenueGeneratedByProductSales'))); - $view->setMetricDocumentation('quantity', Piwik_Translate('Goals_ColumnQuantityDocumentation', $label)); - $view->setMetricDocumentation('orders', Piwik_Translate('Goals_ColumnOrdersDocumentation', $label)); - $view->setMetricDocumentation('avg_price', Piwik_Translate('Goals_ColumnAveragePriceDocumentation', $label)); - $view->setMetricDocumentation('avg_quantity', Piwik_Translate('Goals_ColumnAverageQuantityDocumentation', $label)); - $view->setMetricDocumentation('nb_visits', Piwik_Translate('Goals_ColumnVisitsProductDocumentation', $label)); - $view->setMetricDocumentation('conversion_rate', Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label)); - + $columnsToDisplay = array_merge(array('label'), array_keys($columns)); + $view->setColumnsToDisplay($columnsToDisplay); $view->setSortedColumn('revenue', 'desc'); foreach(array('revenue', 'avg_price') as $column) { $view->queueFilter('ColumnCallbackReplace', array($column, array("Piwik", "getPrettyMoney"), array($this->idSite))); - } - return $this->renderView($view, $fetch); + } + $return = $this->renderView($view, $fetch); + $_GET = $saveGET; + return $return; } - + public function getItemsSku($fetch = false) { return $this->getItemsView($fetch, 'Goals_ProductSKU', __FUNCTION__, "Goals.getItemsSku"); @@ -129,12 +149,13 @@ class Piwik_Goals_Controller extends Piwik_Controller { return $this->getItemsView($fetch, 'Goals_ProductCategory', __FUNCTION__, "Goals.getItemsCategory"); } - public function getOrdersLog($fetch = false) + + public function getEcommerceLog($fetch = false) { $saveGET = $_GET; $_GET['filterEcommerce'] = 1; $_GET['widget'] = 1; - $_GET['segment'] = 'visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart'; + $_GET['segment'] = 'visitEcommerceStatus!=none'; $output = Piwik_FrontController::getInstance()->dispatch('Live', 'getVisitorLog', array($fetch)); $_GET = $saveGET; return $output; @@ -393,3 +414,18 @@ class Piwik_Goals_Controller extends Piwik_Controller return $return; } } + + +// Used so that the template knows which datatable is being currently viewed +class Piwik_ViewDataTable_HtmlTable_EcommerceOrder extends Piwik_ViewDataTable_HtmlTable { + protected function getViewDataTableId() + { + return Piwik_Archive::LABEL_ECOMMERCE_ORDER; + } +} +class Piwik_ViewDataTable_HtmlTable_EcommerceAbandonedCart extends Piwik_ViewDataTable_HtmlTable { + protected function getViewDataTableId() + { + return Piwik_Archive::LABEL_ECOMMERCE_CART; + } +}
\ No newline at end of file diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 1597e6bbc1..fa4f830c8a 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -219,6 +219,7 @@ class Piwik_Goals extends Piwik_Plugin 'conversion_rate' => Piwik_Translate('General_ProductConversionRate'), ); } + static public function getReportsWithGoalMetrics() { $dimensions = array(); @@ -263,7 +264,7 @@ class Piwik_Goals extends Piwik_Plugin if($site->isEcommerceEnabled()) { Piwik_AddWidget('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik_Archive::LABEL_ECOMMERCE_ORDER)); - Piwik_AddWidget('Goals_Ecommerce', 'Goals_EcommerceOrdersLog', 'Goals', 'getOrdersLog'); + Piwik_AddWidget('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog'); foreach($this->ecommerceReports as $widget) { Piwik_AddWidget('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]); diff --git a/plugins/Goals/templates/table_by_dimension.tpl b/plugins/Goals/templates/table_by_dimension.tpl index 77fbe9c892..e832135281 100644 --- a/plugins/Goals/templates/table_by_dimension.tpl +++ b/plugins/Goals/templates/table_by_dimension.tpl @@ -17,8 +17,8 @@ <li class='goalDimension' module='Goals' action='getItemsCategory'> <span class='dimension'>{'Goals_ProductCategory'|translate}</span> </li> - <li class='goalDimension' module='Goals' action='getOrdersLog'> - <span class='dimension'>{'Goals_EcommerceOrdersLog'|translate}</span> + <li class='goalDimension' module='Goals' action='getEcommerceLog'> + <span class='dimension'>{'Goals_EcommerceLog'|translate}</span> </li> </ul> </div> diff --git a/plugins/Live/templates/visitorLog.tpl b/plugins/Live/templates/visitorLog.tpl index a26cdf88d6..de59aa69e9 100644 --- a/plugins/Live/templates/visitorLog.tpl +++ b/plugins/Live/templates/visitorLog.tpl @@ -1,6 +1,6 @@ <div id="{$properties.uniqueId}" class="visitorLog"> {if !$isWidget} - <h2>{if $javascriptVariablesToSet.filterEcommerce}{'Goals_EcommerceOrdersLog'|translate}{else}{'Live_VisitorLog'|translate}{/if}</h2> + <h2>{if $javascriptVariablesToSet.filterEcommerce}{'Goals_EcommerceLog'|translate}{else}{'Live_VisitorLog'|translate}{/if}</h2> {if !empty($reportDocumentation)} <div class="reportDocumentation"><p>{$reportDocumentation}</p></div> @@ -164,7 +164,9 @@ {/foreach} {/if} {/capture} - {if !$javascriptVariablesToSet.filterEcommerce || $action.type == 'ecommerceOrder'} + {if !$javascriptVariablesToSet.filterEcommerce + || $action.type == 'ecommerceOrder' + || $action.type == 'ecommerceAbandonedCart'} <li class="{if !empty($action.goalName)}goal{else}action{/if}" title="{$action.serverTimePretty|escape:'html'}{if !empty($action.url) && strlen(trim($action.url))} - {$action.url|escape:'html'}{/if} {if strlen(trim($customVariablesTooltip))} - {$customVariablesTooltip}{/if}"> {if $action.type == 'ecommerceOrder' || $action.type == 'ecommerceAbandonedCart'} {* Ecommerce Abandoned Cart / Ecommerce Order *} |