update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
75
www/analytics/plugins/Ecommerce/Reports/Base.php
Normal file
75
www/analytics/plugins/Ecommerce/Reports/Base.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Report;
|
||||
use Piwik\Site;
|
||||
|
||||
abstract class Base extends Report
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->module = 'Goals';
|
||||
$this->category = 'Goals_Ecommerce';
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
$idSite = Common::getRequestVar('idSite', false, 'int');
|
||||
|
||||
if (empty($idSite)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isEcommerceEnabled($idSite);
|
||||
}
|
||||
|
||||
public function checkIsEnabled()
|
||||
{
|
||||
if (!$this->isEnabled()) {
|
||||
$message = Piwik::translate('General_ExceptionReportNotEnabled');
|
||||
|
||||
if (Piwik::hasUserSuperUserAccess()) {
|
||||
$message .= ' Most likely Ecommerce is not enabled for the requested site.';
|
||||
}
|
||||
|
||||
throw new \Exception($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function configureReportMetadata(&$availableReports, $infos)
|
||||
{
|
||||
if ($this->isEcommerceEnabledByInfos($infos)) {
|
||||
$availableReports[] = $this->buildReportMetadata();
|
||||
}
|
||||
}
|
||||
|
||||
private function isEcommerceEnabledByInfos($infos)
|
||||
{
|
||||
$idSites = $infos['idSites'];
|
||||
|
||||
if (count($idSites) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$idSite = reset($idSites);
|
||||
|
||||
return $this->isEcommerceEnabled($idSite);
|
||||
}
|
||||
|
||||
private function isEcommerceEnabled($idSite)
|
||||
{
|
||||
$site = new Site($idSite);
|
||||
|
||||
return $site->isEcommerceEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
134
www/analytics/plugins/Ecommerce/Reports/BaseItem.php
Normal file
134
www/analytics/plugins/Ecommerce/Reports/BaseItem.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Metrics\Formatter;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Report;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
|
||||
use Piwik\Plugins\Goals\Goals;
|
||||
use Piwik\Plugins\Goals\Columns\Metrics\AveragePrice;
|
||||
use Piwik\Plugins\Goals\Columns\Metrics\AverageQuantity;
|
||||
use Piwik\Plugins\Goals\Columns\Metrics\ProductConversionRate;
|
||||
|
||||
abstract class BaseItem extends Base
|
||||
{
|
||||
protected $defaultSortColumn = 'revenue';
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->processedMetrics = array(
|
||||
new AveragePrice(),
|
||||
new AverageQuantity(),
|
||||
new ProductConversionRate()
|
||||
);
|
||||
$this->metrics = array(
|
||||
'revenue', 'quantity', 'orders', 'nb_visits'
|
||||
);
|
||||
}
|
||||
|
||||
public function getMetrics()
|
||||
{
|
||||
$metrics = parent::getMetrics();
|
||||
$metrics['revenue'] = Piwik::translate('General_ProductRevenue');
|
||||
$metrics['orders'] = Piwik::translate('General_UniquePurchases');
|
||||
return $metrics;
|
||||
}
|
||||
|
||||
public function getMetricsDocumentation()
|
||||
{
|
||||
if ($this->isAbandonedCart()) {
|
||||
return array(
|
||||
'revenue' => Piwik::translate('Goals_ColumnRevenueDocumentation',
|
||||
Piwik::translate('Goals_DocumentationRevenueGeneratedByProductSales')),
|
||||
'quantity' => Piwik::translate('Goals_ColumnQuantityDocumentation', $this->name),
|
||||
'orders' => Piwik::translate('Goals_ColumnOrdersDocumentation', $this->name),
|
||||
'avg_price' => Piwik::translate('Goals_ColumnAveragePriceDocumentation', $this->name),
|
||||
'avg_quantity' => Piwik::translate('Goals_ColumnAverageQuantityDocumentation', $this->name),
|
||||
'nb_visits' => Piwik::translate('Goals_ColumnVisitsProductDocumentation', $this->name),
|
||||
'conversion_rate' => Piwik::translate('Goals_ColumnConversionRateProductDocumentation', $this->name),
|
||||
);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$idSite = Common::getRequestVar('idSite');
|
||||
|
||||
$view->config->show_ecommerce = true;
|
||||
$view->config->show_table = false;
|
||||
$view->config->show_all_views_icons = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->show_table_all_columns = false;
|
||||
|
||||
if (!($view instanceof Evolution)) {
|
||||
$moneyColumns = array('revenue');
|
||||
$formatter = array(new Formatter(), 'getPrettyMoney');
|
||||
$view->config->filters[] = array('ColumnCallbackReplace', array($moneyColumns, $formatter, array($idSite)));
|
||||
}
|
||||
|
||||
$view->requestConfig->filter_limit = 10;
|
||||
$view->requestConfig->filter_sort_column = 'revenue';
|
||||
$view->requestConfig->filter_sort_order = 'desc';
|
||||
|
||||
$view->config->custom_parameters['isFooterExpandedInDashboard'] = true;
|
||||
|
||||
// set columns/translations which differ based on viewDataTable TODO: shouldn't have to do this check...
|
||||
// amount of reports should be dynamic, but metadata should be static
|
||||
$columns = array_merge($this->getMetrics(), $this->getProcessedMetrics());
|
||||
$columnsOrdered = array('label', 'revenue', 'quantity', 'orders', 'avg_price', 'avg_quantity',
|
||||
'nb_visits', 'conversion_rate');
|
||||
|
||||
// handle old case where viewDataTable is set to ecommerceOrder/ecommerceAbandonedCart. in this case, we
|
||||
// set abandonedCarts accordingly and remove the ecommerceOrder/ecommerceAbandonedCart as viewDataTable.
|
||||
$viewDataTable = Common::getRequestVar('viewDataTable', '');
|
||||
if ($viewDataTable == 'ecommerceOrder') {
|
||||
$view->config->custom_parameters['viewDataTable'] = 'table';
|
||||
$abandonedCart = false;
|
||||
} else if ($viewDataTable == 'ecommerceAbandonedCart') {
|
||||
$view->config->custom_parameters['viewDataTable'] = 'table';
|
||||
$abandonedCart = true;
|
||||
} else {
|
||||
$abandonedCart = $this->isAbandonedCart();
|
||||
}
|
||||
|
||||
if ($abandonedCart) {
|
||||
$columns['abandoned_carts'] = Piwik::translate('General_AbandonedCarts');
|
||||
$columns['revenue'] = Piwik::translate('Goals_LeftInCart', $columns['revenue']);
|
||||
$columns['quantity'] = Piwik::translate('Goals_LeftInCart', $columns['quantity']);
|
||||
$columns['avg_quantity'] = Piwik::translate('Goals_LeftInCart', $columns['avg_quantity']);
|
||||
unset($columns['orders']);
|
||||
unset($columns['conversion_rate']);
|
||||
|
||||
$columnsOrdered = array('label', 'revenue', 'quantity', 'avg_price', 'avg_quantity', 'nb_visits',
|
||||
'abandoned_carts');
|
||||
|
||||
$view->config->custom_parameters['abandonedCarts'] = '1';
|
||||
} else {
|
||||
$view->config->custom_parameters['abandonedCarts'] = '0';
|
||||
}
|
||||
|
||||
$view->requestConfig->request_parameters_to_modify['abandonedCarts'] = $view->config->custom_parameters['abandonedCarts'];
|
||||
|
||||
$translations = array_merge(array('label' => $this->name), $columns);
|
||||
|
||||
$view->config->addTranslations($translations);
|
||||
$view->config->columns_to_display = $columnsOrdered;
|
||||
}
|
||||
|
||||
private function isAbandonedCart()
|
||||
{
|
||||
return Common::getRequestVar('abandonedCarts', '0', 'string') == 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Goals\Columns\DaysToConversion;
|
||||
|
||||
class GetDaysToConversionAbandonedCart extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->action = 'getDaysToConversion';
|
||||
$this->name = Piwik::translate('General_AbandonedCarts') . ' - ' . Piwik::translate('Goals_DaysToConv');
|
||||
$this->dimension = new DaysToConversion();
|
||||
$this->constantRowsCount = true;
|
||||
$this->processedMetrics = false;
|
||||
$this->metrics = array('nb_conversions');
|
||||
$this->order = 25;
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Goals\Columns\DaysToConversion;
|
||||
|
||||
class GetDaysToConversionEcommerceOrder extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->action = 'getDaysToConversion';
|
||||
$this->name = Piwik::translate('General_EcommerceOrders') . ' - ' . Piwik::translate('Goals_DaysToConv');
|
||||
$this->dimension = new DaysToConversion();
|
||||
$this->constantRowsCount = true;
|
||||
$this->processedMetrics = false;
|
||||
$this->metrics = array('nb_conversions');
|
||||
$this->order = 12;
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
|
||||
class GetEcommerceAbandonedCart extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->action = 'get';
|
||||
$this->name = Piwik::translate('General_AbandonedCarts');
|
||||
$this->processedMetrics = array('avg_order_revenue');
|
||||
$this->order = 15;
|
||||
$this->metrics = array('nb_conversions', 'conversion_rate', 'revenue', 'items');
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
|
||||
}
|
||||
|
||||
public function getMetrics() {
|
||||
$metrics = parent::getMetrics();
|
||||
|
||||
$metrics['nb_conversions'] = Piwik::translate('General_AbandonedCarts');
|
||||
$metrics['revenue'] = Piwik::translate('Goals_LeftInCart', Piwik::translate('General_ColumnRevenue'));
|
||||
$metrics['items'] = Piwik::translate('Goals_LeftInCart', Piwik::translate('Goals_Products'));
|
||||
|
||||
return $metrics;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
|
||||
class GetEcommerceOrder extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->action = 'get';
|
||||
$this->name = Piwik::translate('General_EcommerceOrders');
|
||||
$this->processedMetrics = array('avg_order_revenue');
|
||||
$this->order = 10;
|
||||
$this->metrics = array(
|
||||
'nb_conversions',
|
||||
'nb_visits_converted',
|
||||
'conversion_rate',
|
||||
'revenue',
|
||||
'revenue_subtotal',
|
||||
'revenue_tax',
|
||||
'revenue_shipping',
|
||||
'revenue_discount'
|
||||
);
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
|
||||
}
|
||||
|
||||
public function getMetrics()
|
||||
{
|
||||
$metrics = parent::getMetrics();
|
||||
|
||||
$metrics['nb_conversions'] = Piwik::translate('General_EcommerceOrders');
|
||||
$metrics['items'] = Piwik::translate('General_PurchasedProducts');
|
||||
|
||||
return $metrics;
|
||||
}
|
||||
}
|
||||
25
www/analytics/plugins/Ecommerce/Reports/GetItemsCategory.php
Normal file
25
www/analytics/plugins/Ecommerce/Reports/GetItemsCategory.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Ecommerce\Columns\ProductCategory;
|
||||
|
||||
class GetItemsCategory extends BaseItem
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->name = Piwik::translate('Goals_ProductCategory');
|
||||
$this->dimension = new ProductCategory();
|
||||
$this->order = 32;
|
||||
$this->widgetTitle = 'Goals_ProductCategory';
|
||||
}
|
||||
}
|
||||
25
www/analytics/plugins/Ecommerce/Reports/GetItemsName.php
Normal file
25
www/analytics/plugins/Ecommerce/Reports/GetItemsName.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Ecommerce\Columns\ProductName;
|
||||
|
||||
class GetItemsName extends BaseItem
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->name = Piwik::translate('Goals_ProductName');
|
||||
$this->dimension = new ProductName();
|
||||
$this->order = 31;
|
||||
$this->widgetTitle = 'Goals_ProductName';
|
||||
}
|
||||
}
|
||||
27
www/analytics/plugins/Ecommerce/Reports/GetItemsSku.php
Normal file
27
www/analytics/plugins/Ecommerce/Reports/GetItemsSku.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Ecommerce\Columns\ProductSku;
|
||||
|
||||
class GetItemsSku extends BaseItem
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->name = Piwik::translate('Goals_ProductSKU');
|
||||
$this->dimension = new ProductSku();
|
||||
$this->order = 30;
|
||||
$this->widgetTitle = 'Goals_ProductSKU';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Goals\Columns\VisitsUntilConversion;
|
||||
|
||||
class GetVisitsUntilConversionAbandonedCart extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->action = 'getVisitsUntilConversion';
|
||||
$this->name = Piwik::translate('General_AbandonedCarts') . ' - ' . Piwik::translate('Goals_VisitsUntilConv');
|
||||
$this->dimension = new VisitsUntilConversion();
|
||||
$this->constantRowsCount = true;
|
||||
$this->processedMetrics = false;
|
||||
$this->metrics = array('nb_conversions');
|
||||
$this->order = 20;
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\Ecommerce\Reports;
|
||||
|
||||
use Piwik\Metrics;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\Goals\Columns\VisitsUntilConversion;
|
||||
|
||||
class GetVisitsUntilConversionEcommerceOrder extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->action = 'getVisitsUntilConversion';
|
||||
$this->name = Piwik::translate('General_EcommerceOrders') . ' - ' . Piwik::translate('Goals_VisitsUntilConv');
|
||||
$this->dimension = new VisitsUntilConversion();
|
||||
$this->constantRowsCount = true;
|
||||
$this->processedMetrics = array();
|
||||
$this->metrics = array('nb_conversions');
|
||||
$this->order = 11;
|
||||
|
||||
$this->parameters = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue