Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-07-03 03:54:27 +0300
committersgiehl <stefan@piwik.org>2015-10-06 18:25:13 +0300
commit9ba8f216fd7856ce5fef06bf82ecb8f8a2e7e630 (patch)
tree6ce07d18a85d00b39ab720abe042361c0775aead /plugins/Goals
parent8ccc9dc05da021325cdbf141a548637fa52f16b2 (diff)
generate pages instead of implementing them in each controller
Diffstat (limited to 'plugins/Goals')
-rw-r--r--plugins/Goals/API.php3
-rw-r--r--plugins/Goals/Categories/AddANewGoalSubcategory.php19
-rw-r--r--plugins/Goals/Categories/GoalsCategory.php17
-rw-r--r--plugins/Goals/Categories/GoalsOverviewSubcategory.php19
-rw-r--r--plugins/Goals/Categories/ManageGoalsSubcategory.php19
-rw-r--r--plugins/Goals/Controller.php251
-rw-r--r--plugins/Goals/Conversions.php45
-rw-r--r--plugins/Goals/Goals.php58
-rw-r--r--plugins/Goals/Menu.php43
-rw-r--r--plugins/Goals/Pages.php339
-rw-r--r--plugins/Goals/Reports/Base.php2
-rw-r--r--plugins/Goals/Reports/Get.php111
-rw-r--r--plugins/Goals/Widgets.php39
-rw-r--r--plugins/Goals/Widgets/AddNewGoal.php38
-rw-r--r--plugins/Goals/Widgets/EditGoals.php37
-rw-r--r--plugins/Goals/lang/en.json5
-rw-r--r--plugins/Goals/templates/_titleAndEvolutionGraph.twig86
-rw-r--r--plugins/Goals/templates/addNewGoal.twig1
-rw-r--r--plugins/Goals/templates/conversionOverview.twig15
-rw-r--r--plugins/Goals/templates/editGoals.twig2
-rw-r--r--plugins/Goals/templates/getGoalReportView.twig66
-rw-r--r--plugins/Goals/templates/getOverviewView.twig58
22 files changed, 764 insertions, 509 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index 80a898fe34..351e700782 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -22,6 +22,7 @@ use Piwik\Plugin\Report;
use Piwik\Plugins\API\DataTable\MergeDataTables;
use Piwik\Plugins\CoreHome\Columns\Metrics\ConversionRate;
use Piwik\Plugins\Goals\Columns\Metrics\AverageOrderRevenue;
+use Piwik\Plugin\Reports;
use Piwik\Segment\SegmentExpression;
use Piwik\Site;
use Piwik\Tracker\Cache;
@@ -414,7 +415,7 @@ class API extends \Piwik\Plugin\API
$requestedColumns = array_unique(array_merge($requestedColumns, $metricsToAdd));
}
- $report = Report::factory('Goals', 'getMetrics');
+ $report = Reports::factory('Goals', 'getMetrics');
$columnsToGet = $report->getMetricsRequiredForReport($allMetrics, $requestedColumns);
$inDbMetricNames = array_map(function ($name) use ($idGoal) {
diff --git a/plugins/Goals/Categories/AddANewGoalSubcategory.php b/plugins/Goals/Categories/AddANewGoalSubcategory.php
new file mode 100644
index 0000000000..9b613f2e55
--- /dev/null
+++ b/plugins/Goals/Categories/AddANewGoalSubcategory.php
@@ -0,0 +1,19 @@
+<?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\Goals\Categories;
+
+use Piwik\Category\Subcategory;
+
+class AddANewGoalSubcategory extends Subcategory
+{
+ protected $categoryId = 'Goals_Goals';
+ protected $id = 'Goals_AddNewGoal';
+ protected $order = 9999;
+
+}
diff --git a/plugins/Goals/Categories/GoalsCategory.php b/plugins/Goals/Categories/GoalsCategory.php
new file mode 100644
index 0000000000..7ba4b4df58
--- /dev/null
+++ b/plugins/Goals/Categories/GoalsCategory.php
@@ -0,0 +1,17 @@
+<?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\Goals\Categories;
+
+use Piwik\Category\Category;
+
+class GoalsCategory extends Category
+{
+ protected $id = 'Goals_Goals';
+ protected $order = 25;
+}
diff --git a/plugins/Goals/Categories/GoalsOverviewSubcategory.php b/plugins/Goals/Categories/GoalsOverviewSubcategory.php
new file mode 100644
index 0000000000..95f2d815c9
--- /dev/null
+++ b/plugins/Goals/Categories/GoalsOverviewSubcategory.php
@@ -0,0 +1,19 @@
+<?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\Goals\Categories;
+
+use Piwik\Category\Subcategory;
+
+class GoalsOverviewSubcategory extends Subcategory
+{
+ protected $categoryId = 'Goals_Goals';
+ protected $id = 'General_Overview';
+ protected $order = 2;
+
+}
diff --git a/plugins/Goals/Categories/ManageGoalsSubcategory.php b/plugins/Goals/Categories/ManageGoalsSubcategory.php
new file mode 100644
index 0000000000..ef71697981
--- /dev/null
+++ b/plugins/Goals/Categories/ManageGoalsSubcategory.php
@@ -0,0 +1,19 @@
+<?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\Goals\Categories;
+
+use Piwik\Category\Subcategory;
+
+class ManageGoalsSubcategory extends Subcategory
+{
+ protected $categoryId = 'Goals_Goals';
+ protected $id = 'Goals_ManageGoals';
+ protected $order = 9999;
+
+}
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 15f7b40aab..966005b690 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -8,16 +8,16 @@
*/
namespace Piwik\Plugins\Goals;
-use Exception;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\DataTable\Renderer\Json;
use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
+use Piwik\FrontController;
use Piwik\Piwik;
use Piwik\Plugins\Referrers\API as APIReferrers;
use Piwik\Translation\Translator;
use Piwik\View;
-use Piwik\View\ReportsByDimension;
/**
*
@@ -48,11 +48,6 @@ class Controller extends \Piwik\Plugin\Controller
*/
private $translator;
- /**
- * @var TranslationHelper
- */
- private $translationHelper;
-
private function formatConversionRate($conversionRate, $columnName = 'conversion_rate')
{
if ($conversionRate instanceof DataTable) {
@@ -70,89 +65,16 @@ class Controller extends \Piwik\Plugin\Controller
return $conversionRate;
}
- public function __construct(Translator $translator, TranslationHelper $translationHelper)
+ public function __construct(Translator $translator)
{
parent::__construct();
$this->translator = $translator;
- $this->translationHelper = $translationHelper;
$this->idSite = Common::getRequestVar('idSite', null, 'int');
$this->goals = API::getInstance()->getGoals($this->idSite);
}
- public function widgetGoalReport()
- {
- $view = $this->getGoalReportView($idGoal = Common::getRequestVar('idGoal', null, 'string'));
- $view->displayFullReport = false;
- return $view->render();
- }
-
- public function goalReport()
- {
- $view = $this->getGoalReportView($idGoal = Common::getRequestVar('idGoal', null, 'string'));
- $view->displayFullReport = true;
- return $view->render();
- }
-
- protected function getGoalReportView($idGoal = false)
- {
- $view = new View('@Goals/getGoalReportView');
- if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
- $goalDefinition['name'] = $this->translator->translate('Goals_Ecommerce');
- $goalDefinition['allow_multiple'] = true;
- $ecommerce = $view->ecommerce = true;
- } else {
- if (!isset($this->goals[$idGoal])) {
- Piwik::redirectToModule('Goals', 'index', array('idGoal' => null));
- }
- $goalDefinition = $this->goals[$idGoal];
- }
- $this->setGeneralVariablesView($view);
- $goal = $this->getMetricsForGoal($idGoal);
- foreach ($goal as $name => $value) {
- $view->$name = $value;
- }
- if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
- $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
- foreach ($goal as $name => $value) {
- $name = 'cart_' . $name;
- $view->$name = $value;
- }
- }
- $view->showHeadline = false;
- $view->idGoal = $idGoal;
- $view->goalName = $goalDefinition['name'];
- $view->goalAllowMultipleConversionsPerVisit = $goalDefinition['allow_multiple'];
- $view->graphEvolution = $this->getEvolutionGraph(array(), $idGoal, array('nb_conversions'));
- $view->nameGraphEvolution = 'Goals.getEvolutionGraph' . $idGoal;
- $view->topDimensions = $this->getTopDimensions($idGoal);
-
- $goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
-
- // conversion rate for new and returning visitors
- $view->conversion_rate_returning = $this->formatConversionRate($goalMetrics, 'conversion_rate_returning_visit');
- $view->conversion_rate_new = $this->formatConversionRate($goalMetrics, 'conversion_rate_new_visit');
-
- $view->goalReportsByDimension = $this->getGoalReportsByDimensionTable(
- $view->nb_conversions, isset($ecommerce), !empty($view->cart_nb_conversions));
- return $view;
- }
-
- public function index()
- {
- $view = $this->getOverviewView();
-
- // unsanitize goal names and other text data (not done in API so as not to break
- // any other code/cause security issues)
- $goals = $this->goals;
- $view->goalsJSON = json_encode($goals);
-
- $view->ecommerceEnabled = $this->site->isEcommerceEnabled();
- $view->displayFullReport = true;
- return $view->render();
- }
-
public function manage()
{
Piwik::checkUserHasAdminAccess($this->idSite);
@@ -164,48 +86,20 @@ class Controller extends \Piwik\Plugin\Controller
return $view->render();
}
- public function widgetGoalsOverview()
+ public function goalConversionsOverview()
{
- $view = $this->getOverviewView();
- $view->displayFullReport = false;
- return $view->render();
- }
+ $view = new View('@Goals/conversionOverview');
+ $idGoal = Common::getRequestVar('idGoal', null, 'string');
- protected function getOverviewView()
- {
- $view = new View('@Goals/getOverviewView');
- $this->setGeneralVariablesView($view);
-
- $view->graphEvolution = $this->getEvolutionGraph(array(), false, array('nb_conversions'));
- $view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
-
- // sparkline for the historical data of the above values
- $view->urlSparklineConversions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_conversions'), 'idGoal' => ''));
- $view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('conversion_rate'), 'idGoal' => ''));
- $view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('revenue'), 'idGoal' => ''));
-
- // Pass empty idGoal will return Goal overview
- $request = new Request("method=Goals.get&format=original&idGoal=");
- $datatable = $request->process();
- $dataRow = $datatable->getFirstRow();
+ $view->topDimensions = $this->getTopDimensions($idGoal);
- $view->nb_conversions = $dataRow->getColumn('nb_conversions');
- $view->nb_visits_converted = $dataRow->getColumn('nb_visits_converted');
- $view->conversion_rate = $this->formatConversionRate($dataRow->getColumn('conversion_rate'));
- $view->revenue = $dataRow->getColumn('revenue');
+ $goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
- $goalMetrics = array();
- foreach ($this->goals as $idGoal => $goal) {
- $goalMetrics[$idGoal] = $this->getMetricsForGoal($idGoal);
- $goalMetrics[$idGoal]['name'] = $goal['name'];
- $goalMetrics[$idGoal]['goalAllowMultipleConversionsPerVisit'] = $goal['allow_multiple'];
- }
+ // conversion rate for new and returning visitors
+ $view->conversion_rate_returning = $this->formatConversionRate($goalMetrics, 'conversion_rate_returning_visit');
+ $view->conversion_rate_new = $this->formatConversionRate($goalMetrics, 'conversion_rate_new_visit');
- $view->goalMetrics = $goalMetrics;
- $view->goals = $this->goals;
- $view->goalReportsByDimension = $this->getGoalReportsByDimensionTable(
- $view->nb_conversions, $ecommerce = false, !empty($view->cart_nb_conversions));
- return $view;
+ return $view->render();
}
public function getLastNbConversionsGraph()
@@ -244,6 +138,26 @@ class Controller extends \Piwik\Plugin\Controller
return $view->render();
}
+ public function hasConversions()
+ {
+ $this->checkSitePermission();
+
+ $idGoal = Common::getRequestVar('idGoal', '', 'string');
+ $idSite = Common::getRequestVar('idSite', null, 'int');
+ $period = Common::getRequestVar('period', null, 'string');
+ $date = Common::getRequestVar('date', null, 'string');
+
+ Piwik::checkUserHasViewAccess($idSite);
+
+ $conversions = new Conversions();
+
+ Json::sendHeaderJSON();
+
+ $numConversions = $conversions->getConversionForGoal($idGoal, $idSite, $period, $date);
+
+ return json_encode($numConversions > 0);
+ }
+
public function getEvolutionGraph(array $columns = array(), $idGoal = false, array $defaultColumns = array())
{
if (empty($columns)) {
@@ -334,11 +248,11 @@ class Controller extends \Piwik\Plugin\Controller
$topDimensions = array();
foreach ($topDimensionsToLoad as $dimensionName => $apiMethod) {
$request = new Request("method=$apiMethod
- &format=original
- &filter_update_columns_when_show_all_goals=1
- &idGoal=" . AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE . "
- &filter_sort_order=desc
- &filter_sort_column=$columnNbConversions" .
+ &format=original
+ &filter_update_columns_when_show_all_goals=1
+ &idGoal=" . AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE . "
+ &filter_sort_order=desc
+ &filter_sort_column=$columnNbConversions" .
// select a couple more in case some are not valid (ie. conversions==0 or they are "Keyword not defined")
"&filter_limit=" . (self::COUNT_TOP_ROWS_TO_DISPLAY + 2));
$datatable = $request->process();
@@ -402,72 +316,11 @@ class Controller extends \Piwik\Plugin\Controller
'avg_order_revenue' => $aov ? $aov : 0,
'urlSparklinePurchasedProducts' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('items'), 'idGoal' => $idGoal)),
'urlSparklineAverageOrderValue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_order_revenue'), 'idGoal' => $idGoal)),
- ));
+ ));
}
return $return;
}
- /**
- * Utility function that returns HTML that displays Goal information for reports. This
- * is the HTML that is at the bottom of every goals page.
- *
- * @param int $conversions The number of conversions for this goal (or all goals
- * in case of the overview).
- * @param bool $ecommerce Whether to show ecommerce reports or not.
- * @param bool $cartNbConversions Whether there are cart conversions or not for this
- * goal.
- * @return string
- */
- private function getGoalReportsByDimensionTable($conversions, $ecommerce = false, $cartNbConversions = false)
- {
- $preloadAbandonedCart = $cartNbConversions !== false && $conversions == 0;
-
- $goalReportsByDimension = new ReportsByDimension('Goals');
-
- // add ecommerce reports
- $ecommerceCustomParams = array();
- if ($ecommerce) {
- if ($preloadAbandonedCart) {
- $ecommerceCustomParams['abandonedCarts'] = '1';
- } else {
- $ecommerceCustomParams['abandonedCarts'] = '0';
- }
- }
-
- if ($conversions > 0 || $ecommerce) {
- // for non-Goals reports, we show the goals table
- $customParams = $ecommerceCustomParams + array('documentationForGoalsPage' => '1');
-
- if (Common::getRequestVar('idGoal', '') === '') // if no idGoal, use 0 for overview
- {
- $customParams['idGoal'] = '0'; // NOTE: Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
- }
-
- $allReports = Goals::getReportsWithGoalMetrics();
- foreach ($allReports as $category => $reports) {
- if ($ecommerce) {
- $categoryText = $this->translationHelper->translateEcommerceMetricCategory($category);
- } else {
- $categoryText = $this->translationHelper->translateGoalMetricCategory($category);
- }
-
- foreach ($reports as $report) {
- if (empty($report['viewDataTable'])
- && empty($report['abandonedCarts'])
- ) {
- $report['viewDataTable'] = 'tableGoals';
- }
- $customParams['viewDataTable'] = $report['viewDataTable'];
-
- $goalReportsByDimension->addReport(
- $categoryText, $report['name'], $report['module'] . '.' . $report['action'], $customParams);
- }
- }
- }
-
- return $goalReportsByDimension->render();
- }
-
private function setEditGoalsViewVariables($view)
{
$goals = $this->goals;
@@ -496,4 +349,32 @@ class Controller extends \Piwik\Plugin\Controller
{
$view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
}
+
+ /**
+ * @deprecated used to be a widgetized URL. There to not break widget URLs
+ */
+ public function widgetGoalReport()
+ {
+ $idGoal = Common::getRequestVar('idGoal', '', 'string');
+
+ if ($idGoal === Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
+ $_GET['containerId'] = 'EcommerceOverview';
+ } elseif (!empty($idGoal)) {
+ $_GET['containerId'] = 'Goal_' . (int) $idGoal;
+ } else {
+ return '';
+ }
+
+ return FrontController::getInstance()->fetchDispatch('CoreHome', 'renderWidgetContainer');
+ }
+
+ /**
+ * @deprecated used to be a widgetized URL. There to not break widget URLs
+ */
+ public function widgetGoalsOverview()
+ {
+ $_GET['containerId'] = 'GoalsOverview';
+
+ return FrontController::getInstance()->fetchDispatch('CoreHome', 'renderWidgetContainer');
+ }
}
diff --git a/plugins/Goals/Conversions.php b/plugins/Goals/Conversions.php
new file mode 100644
index 0000000000..fbbbef0078
--- /dev/null
+++ b/plugins/Goals/Conversions.php
@@ -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\Goals;
+
+use Piwik\API\Request;
+use Piwik\Cache;
+use Piwik\Common;
+use Piwik\Db;
+
+class Conversions
+{
+
+ public function getConversionForGoal($idGoal, $idSite, $period, $date)
+ {
+ if (!$period || !$date || !$idSite) {
+ return false;
+ }
+
+ $datatable = Request::processRequest('Goals.get', array(
+ 'idGoal' => $idGoal,
+ 'period' => $period,
+ 'date' => $date,
+ 'idSite' => $idSite,
+ 'serialize' => 0,
+ 'segment' => false
+ ));
+
+ // we ignore the segment even if there is one set. We still want to show conversion overview if there are conversions
+ // in general but not for this segment
+
+ $dataRow = $datatable->getFirstRow();
+
+ if (!$dataRow) {
+ return false;
+ }
+
+ return $dataRow->getColumn('nb_conversions');
+ }
+}
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index d26e2cf77e..609d98c419 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -13,8 +13,9 @@ use Piwik\Common;
use Piwik\Db;
use Piwik\Piwik;
use Piwik\Plugin\Report;
+use Piwik\Plugin\Reports;
use Piwik\Tracker\GoalManager;
-use Piwik\Translate;
+use Piwik\Category\Subcategory;
/**
*
@@ -29,36 +30,17 @@ class Goals extends \Piwik\Plugin
foreach ($dimensions as $dimension) {
$group = $dimension['category'];
// move "Custom Variables" report to the "Goals/Sales by User attribute" category
- if ($dimension['module'] === 'CustomVariables') {
+ if ($dimension['module'] === 'CustomVariables'
+ || $dimension['action'] == 'getVisitInformationPerServerTime') {
$group = 'VisitsSummary_VisitsSummary';
}
unset($dimension['category']);
$dimensionsByGroup[$group][] = $dimension;
}
- uksort($dimensionsByGroup, array('self', 'sortGoalDimensionsByModule'));
return $dimensionsByGroup;
}
- public static function sortGoalDimensionsByModule($a, $b)
- {
- static $order = null;
-
- if (is_null($order)) {
- $order = array(
- 'Referrers_Referrers',
- 'General_Visit',
- 'General_Visitors',
- 'VisitsSummary_VisitsSummary',
- 'VisitTime_ColumnServerTime',
- );
- }
-
- $orderA = array_search($a, $order);
- $orderB = array_search($b, $order);
- return $orderA > $orderB;
- }
-
public static function getGoalColumns($idGoal)
{
$columns = array(
@@ -98,11 +80,34 @@ class Goals extends \Piwik\Plugin
'SitesManager.deleteSite.end' => 'deleteSiteGoals',
'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
- 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations'
+ 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations',
+ 'Category.addSubcategories' => 'addSubcategories'
);
return $hooks;
}
+ public function addSubcategories(&$subcategories)
+ {
+ $idSite = Common::getRequestVar('idSite', 0, 'int');
+
+ if (!$idSite) {
+ return;
+ }
+
+ $goals = API::getInstance()->getGoals($idSite);
+
+ $order = 900;
+ foreach ($goals as $goal) {
+ $category = new Subcategory();
+ $category->setName($goal['name']);
+ $category->setCategoryId('Goals_Goals');
+ $category->setId($goal['idgoal']);
+ $category->setOrder($order++);
+ $subcategories[] = $category;
+ }
+ }
+
+
public function addMetricTranslations(&$translations)
{
$metrics = array(
@@ -176,10 +181,12 @@ class Goals extends \Piwik\Plugin
{
$reportsWithGoals = array();
- foreach (Report::getAllReports() as $report) {
+ $reports = new Reports();
+
+ foreach ($reports->getAllReports() as $report) {
if ($report->hasGoalMetrics()) {
$reportsWithGoals[] = array(
- 'category' => $report->getCategoryKey(),
+ 'category' => $report->getCategoryId(),
'name' => $report->getName(),
'module' => $report->getModule(),
'action' => $report->getAction(),
@@ -271,5 +278,6 @@ class Goals extends \Piwik\Plugin
$translationKeys[] = 'Goals_DeleteGoalConfirm';
$translationKeys[] = 'Goals_Ecommerce';
$translationKeys[] = 'Goals_Optional';
+ $translationKeys[] = 'Goals_ChooseGoal';
}
}
diff --git a/plugins/Goals/Menu.php b/plugins/Goals/Menu.php
index 85db036797..503c7e0430 100644
--- a/plugins/Goals/Menu.php
+++ b/plugins/Goals/Menu.php
@@ -10,7 +10,6 @@ namespace Piwik\Plugins\Goals;
use Piwik\Common;
use Piwik\Menu\Group;
-use Piwik\Menu\MenuReporting;
use Piwik\Menu\MenuUser;
use Piwik\Piwik;
use Piwik\Plugins\UsersManager\UserPreferences;
@@ -18,48 +17,6 @@ use Piwik\Translate;
class Menu extends \Piwik\Plugin\Menu
{
- public function configureReportingMenu(MenuReporting $menu)
- {
- $idSite = $this->getIdSite();
- $goals = API::getInstance()->getGoals($idSite);
- $mainGoalMenu = 'Goals_Goals';
-
- if (count($goals) == 0) {
- $linkToAddNewGoal = $this->urlForAction('addNewGoal', array(
- 'idGoal' => null,
- ));
- $menu->addItem($mainGoalMenu, '', $linkToAddNewGoal, 25);
- $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $linkToAddNewGoal, 1);
- return;
- }
-
- $order = 1;
-
- $url = $this->urlForAction('index', array('idGoal' => null));
-
- $menu->addItem($mainGoalMenu, '', $url, 25);
- $menu->addItem($mainGoalMenu, 'General_Overview', $url, ++$order);
-
- $group = new Group();
- foreach ($goals as $goal) {
- $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
- $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal']));
- $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
-
- if (count($goals) > 3) {
- $group->add($subMenuName, $params, $tooltip);
- } else {
- $menu->addItem($mainGoalMenu, $subMenuName, $params, ++$order, $tooltip);
- }
- }
-
- if (count($goals) > 3) {
- $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, ++$order, $tooltip = false);
- }
-
- $menu->addItem($mainGoalMenu, 'Goals_ManageGoals', $this->urlForAction('editGoals'), ++$order);
- }
-
public function configureUserMenu(MenuUser $menu)
{
$userPreferences = new UserPreferences();
diff --git a/plugins/Goals/Pages.php b/plugins/Goals/Pages.php
new file mode 100644
index 0000000000..9ab7a96d66
--- /dev/null
+++ b/plugins/Goals/Pages.php
@@ -0,0 +1,339 @@
+<?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\Goals;
+
+
+use Piwik\API\Request;
+use Piwik\Cache;
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugin\Report;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
+use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines;
+use Piwik\Plugin\Reports;
+use Piwik\Widget\WidgetContainerConfig;
+use Piwik\Widget\WidgetConfig;
+use Piwik\Report\ReportWidgetFactory;
+
+class Pages
+{
+ private $orderId = 0;
+ private $allReports = array();
+ private $factory = array();
+ private $conversions;
+
+ public function __construct(ReportWidgetFactory $reportFactory, $reportsWithGoalMetrics)
+ {
+ $this->factory = $reportFactory;
+ $this->allReports = $reportsWithGoalMetrics;
+ $this->conversions = new Conversions();
+ }
+
+ /**
+ * @param array $goals
+ * @return WidgetConfig[]
+ */
+ public function createGoalsOverviewPage($goals)
+ {
+ $subcategory = 'General_Overview';
+
+ $widgets = array();
+
+ $config = $this->factory->createWidget();
+ $config->forceViewDataTable(Evolution::ID);
+ $config->setSubcategoryId($subcategory);
+ $config->setAction('getEvolutionGraph');
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
+
+ $config = $this->factory->createWidget();
+ $config->forceViewDataTable(Sparklines::ID);
+ $config->setSubcategoryId($subcategory);
+ $config->setName('');
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
+
+ foreach ($goals as $goal) {
+ $name = Common::sanitizeInputValue($goal['name']);
+ $goalTranslated = Piwik::translate('Goals_GoalX', array($name));
+
+ $config = $this->factory->createWidget();
+ $config->setName($goalTranslated);
+ $config->setSubcategoryId($subcategory);
+ $config->forceViewDataTable(Sparklines::ID);
+ $config->setParameters(array('idGoal' => $goal['idgoal']));
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->addParameters(array('allow_multiple' => (int) $goal['allow_multiple'], 'only_summary' => '1'));
+ $widgets[] = $config;
+ }
+
+ $container = $this->createWidgetizableWidgetContainer('GoalsOverview', $subcategory, $widgets);
+
+ $config = $this->factory->createContainerWidget('Goals');
+ $config->setSubcategoryId($subcategory);
+ $config->setName('Goals_ConversionsOverviewBy');
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $this->buildGoalByDimensionView('', $config);
+ $config->setMiddlewareParameters(array(
+ 'module' => 'Goals',
+ 'action' => 'hasConversions'
+ ));
+
+ return array($container, $config);
+ }
+
+ /**
+ * @return WidgetConfig[]
+ */
+ public function createEcommerceOverviewPage()
+ {
+ $category = 'Goals_Ecommerce';
+ $subcategory = 'General_Overview';
+ $idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
+
+ $widgets = array();
+ $config = $this->factory->createWidget();
+ $config->forceViewDataTable(Evolution::ID);
+ $config->setCategoryId($category);
+ $config->setSubcategoryId($subcategory);
+ $config->setAction('getEvolutionGraph');
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->setParameters(array('idGoal' => $idGoal));
+ $widgets[] = $config;
+
+ $config = $this->factory->createWidget();
+ $config->setCategoryId($category);
+ $config->forceViewDataTable(Sparklines::ID);
+ $config->setSubcategoryId($subcategory);
+ $config->setName('');
+ $config->setModule('Ecommerce');
+ $config->setAction('getSparklines');
+ $config->setParameters(array('idGoal' => $idGoal));
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
+
+ $config = $this->factory->createWidget();
+ $config->setModule('Ecommerce');
+ $config->setAction('getConversionsOverview');
+ $config->setSubcategoryId($idGoal);
+ $config->setName('Goals_ConversionsOverview');
+ $config->setParameters(array('idGoal' => $idGoal));
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->setMiddlewareParameters(array(
+ 'module' => 'Goals',
+ 'action' => 'hasConversions',
+ 'idGoal' => $idGoal
+ ));
+
+ $widgets[] = $config;
+
+ $container = $this->createWidgetizableWidgetContainer('EcommerceOverview', $subcategory, $widgets);
+ return array($container);
+ }
+
+ /**
+ * @return WidgetConfig[]
+ */
+ public function createEcommerceSalesPage()
+ {
+ $category = 'Goals_Ecommerce';
+ $subcategory = 'Ecommerce_Sales';
+
+ $config = $this->factory->createContainerWidget('GoalsOrder');
+ $config->setCategoryId($category);
+ $config->setSubcategoryId($subcategory);
+ $config->setName('');
+ $config->setParameters(array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $this->buildGoalByDimensionView(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER, $config);
+
+ return array($config);
+ }
+
+ /**
+ * @param array $goal
+ * @return WidgetConfig[]
+ */
+ public function createGoalDetailPage($goal)
+ {
+ $widgets = array();
+
+ $idGoal = (int) $goal['idgoal'];
+ $name = Common::sanitizeInputValue($goal['name']);
+ $params = array('idGoal' => $idGoal);
+
+ $config = $this->factory->createWidget();
+ $config->setSubcategoryId($idGoal);
+ $config->forceViewDataTable(Evolution::ID);
+ $config->setAction('getEvolutionGraph');
+ $config->setParameters($params);
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
+
+ $config = $this->factory->createWidget();
+ $config->setSubcategoryId($idGoal);
+ $config->setName('');
+ $config->forceViewDataTable(Sparklines::ID);
+ $config->setParameters($params);
+ $config->addParameters(array('allow_multiple' => (int) $goal['allow_multiple']));
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->setIsNotWidgetizable();
+ $widgets[] = $config;
+
+ $config = $this->factory->createWidget();
+ $config->setAction('goalConversionsOverview');
+ $config->setSubcategoryId($idGoal);
+ $config->setName('Goals_ConversionsOverview');
+ $config->setParameters($params);
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->setMiddlewareParameters(array(
+ 'module' => 'Goals',
+ 'action' => 'hasConversions',
+ 'idGoal' => $idGoal
+ ));
+ $widgets[] = $config;
+
+ $container = $this->createWidgetizableWidgetContainer('Goal_' . $idGoal, $name, $widgets);
+
+ $configs = array($container);
+
+ $config = $this->factory->createContainerWidget('Goals' . $idGoal);
+ $config->setName(Piwik::translate('Goals_GoalConversionsBy', array($name)));
+ $config->setSubcategoryId($idGoal);
+ $config->setParameters(array());
+ $config->setOrder(++$this->orderId);
+ $config->setIsNotWidgetizable();
+ $config->setMiddlewareParameters(array(
+ 'module' => 'Goals',
+ 'action' => 'hasConversions',
+ 'idGoal' => $idGoal
+ ));
+ $this->buildGoalByDimensionView($idGoal, $config);
+
+ $configs[] = $config;
+
+ return $configs;
+ }
+
+ private function createWidgetizableWidgetContainer($containerId, $pageName, $widgets)
+ {
+ /** @var \Piwik\Widget\WidgetConfig[] $widgets */
+ $firstWidget = reset($widgets);
+ /** @var \Piwik\Report\ReportWidgetConfig $firstWidget */
+
+ if (!empty($pageName)) {
+ // make sure to not show two titles (one for this container and one for the first widget)
+ $firstWidget->setName('');
+ }
+
+ $config = $this->factory->createContainerWidget($containerId);
+ $config->setName($pageName);
+ $config->setCategoryId($firstWidget->getCategoryId());
+ $config->setSubcategoryId($firstWidget->getSubcategoryId());
+ $config->setIsWidgetizable();
+ $config->setOrder($this->orderId++);
+
+ foreach ($widgets as $widget) {
+ $config->addWidgetConfig($widget);
+ }
+
+ return $config;
+ }
+
+ private function buildGoalByDimensionView($idGoal, WidgetContainerConfig $container)
+ {
+ $container->setLayout('ByDimension');
+ $ecommerce = ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
+
+ // for non-Goals reports, we show the goals table
+ $customParams = array('documentationForGoalsPage' => '1');
+
+ if ($idGoal === '') {
+ // if no idGoal, use 0 for overview. Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
+ $customParams['idGoal'] = '0';
+ } else {
+ $customParams['idGoal'] = $idGoal;
+ }
+
+ $translationHelper = new TranslationHelper();
+
+ foreach ($this->allReports as $category => $reports) {
+ $order = ($this->getSortOrderOfCategory($category) * 100);
+
+ if ($ecommerce) {
+ $categoryText = $translationHelper->translateEcommerceMetricCategory($category);
+ } else {
+ $categoryText = $translationHelper->translateGoalMetricCategory($category);
+ }
+
+ foreach ($reports as $report) {
+ $order++;
+
+ if (empty($report['viewDataTable'])
+ && empty($report['abandonedCarts'])
+ ) {
+ $report['viewDataTable'] = 'tableGoals';
+ }
+
+ $widget = $this->createWidgetForReport($report['module'], $report['action']);
+ $widget->setParameters($customParams);
+ $widget->setCategoryId($categoryText);
+ $widget->setSubcategoryId($categoryText);
+ $widget->setOrder($order);
+ $widget->setIsNotWidgetizable();
+
+ if (!empty($report['viewDataTable'])) {
+ $widget->setDefaultViewDataTable($report['viewDataTable']);
+ }
+
+ $container->addWidgetConfig($widget);
+ }
+ }
+ }
+
+ private function getSortOrderOfCategory($category)
+ {
+ static $order = null;
+
+ if (is_null($order)) {
+ $order = array(
+ 'Referrers_Referrers',
+ 'General_Visit',
+ 'General_Visitors',
+ 'VisitsSummary_VisitsSummary',
+ );
+ }
+
+ $value = array_search($category, $order);
+
+ if (false === $value) {
+ $value = count($order) + 1;
+ }
+
+ return $value;
+ }
+
+ private function createWidgetForReport($module, $action)
+ {
+ $factory = new ReportWidgetFactory(Reports::factory($module, $action));
+ return $factory->createWidget();
+ }
+
+}
diff --git a/plugins/Goals/Reports/Base.php b/plugins/Goals/Reports/Base.php
index fd732035d3..3f9cb9c98a 100644
--- a/plugins/Goals/Reports/Base.php
+++ b/plugins/Goals/Reports/Base.php
@@ -18,7 +18,7 @@ abstract class Base extends \Piwik\Plugin\Report
protected function init()
{
- $this->category = 'Goals_Goals';
+ $this->categoryId = 'Goals_Goals';
}
protected function addReportMetadataForEachGoal(&$availableReports, $infos, $goalNameFormatter)
diff --git a/plugins/Goals/Reports/Get.php b/plugins/Goals/Reports/Get.php
index bccecda146..66f167fb24 100644
--- a/plugins/Goals/Reports/Get.php
+++ b/plugins/Goals/Reports/Get.php
@@ -8,7 +8,20 @@
*/
namespace Piwik\Plugins\Goals\Reports;
+use Piwik\Common;
+use Piwik\DataTable;
+use Piwik\Metrics\Formatter;
use Piwik\Piwik;
+use Piwik\Plugin;
+use Piwik\Plugin\ViewDataTable;
+use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution;
+use Piwik\Plugins\CoreVisualizations\Visualizations\Sparklines;
+use Piwik\Plugins\Goals\API;
+use Piwik\Plugins\Goals\Goals;
+use Piwik\Plugins\Goals\Pages;
+use Piwik\Report\ReportWidgetFactory;
+use Piwik\Site;
+use Piwik\Widget\WidgetsList;
class Get extends Base
{
@@ -25,6 +38,104 @@ class Get extends Base
$this->parameters = null;
}
+ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory)
+ {
+ $idSite = $this->getIdSite();
+ $goals = API::getInstance()->getGoals($idSite);
+ $reports = Goals::getReportsWithGoalMetrics();
+
+ $page = new Pages($factory, $reports);
+
+ $widgetsList->addWidgetConfigs($page->createGoalsOverviewPage($goals));
+
+ if ($this->isEcommerceEnabled($idSite)) {
+ $widgetsList->addWidgetConfigs($page->createEcommerceOverviewPage());
+ $widgetsList->addWidgetConfigs($page->createEcommerceSalesPage());
+ }
+
+ foreach ($goals as $goal) {
+ $widgetsList->addWidgetConfigs($page->createGoalDetailPage($goal));
+ }
+ }
+
+ private function getIdSite()
+ {
+ return Common::getRequestVar('idSite', null, 'int');
+ }
+
+ private function isEcommerceEnabled($idSite)
+ {
+ if (!Plugin\Manager::getInstance()->isPluginActivated('Ecommerce')) {
+ return false;
+ }
+
+ $site = new Site($idSite);
+ return $site->isEcommerceEnabled();
+ }
+
+ public function configureView(ViewDataTable $view)
+ {
+ if ($view->isViewDataTableId(Sparklines::ID)) {
+ /** @var Sparklines $view */
+ $idSite = $this->getIdSite();
+ $isEcommerceEnabled = $this->isEcommerceEnabled($idSite);
+
+ $idGoal = Common::getRequestVar('idGoal', 0, 'int');
+
+ $formatter = new Formatter();
+ $view->config->filters[] = function (DataTable $table) use ($formatter, $idSite) {
+ $firstRow = $table->getFirstRow();
+ if ($firstRow) {
+ $revenue = $firstRow->getColumn('revenue');
+ $firstRow->setColumn('revenue', $formatter->getPrettyMoney($revenue, $idSite));
+ }
+ };
+
+ $view->config->addTranslations(array(
+ 'nb_visits' => Piwik::translate('VisitsSummary_NbVisitsDescription'),
+ 'nb_conversions' => Piwik::translate('Goals_ConversionsDescription'),
+ 'nb_visits_converted' => Piwik::translate('General_NVisits'),
+ 'conversion_rate' => Piwik::translate('Goals_OverallConversionRate'),
+ 'revenue' => Piwik::translate('Goals_OverallRevenue'),
+ ));
+
+ $allowMultiple = Common::getRequestVar('allow_multiple', 0, 'int');
+
+ if ($allowMultiple) {
+ $view->config->addSparklineMetric(array('nb_conversions', 'nb_visits_converted'), $order = 10);
+ } else {
+ $view->config->addSparklineMetric(array('nb_conversions'), $order = 10);
+ }
+
+ $view->config->addSparklineMetric(array('conversion_rate'), $order = 20);
+
+ if (empty($idGoal)) {
+ // goals overview sparklines below evolution graph
+
+ if ($isEcommerceEnabled) {
+ // this would be ideally done in Ecommerce plugin but then it is hard to keep same order
+ $view->config->addSparklineMetric(array('revenue'), $order = 30);
+ }
+
+ } else {
+ $onlySummary = Common::getRequestVar('only_summary', 0, 'int');
+
+ if ($onlySummary) {
+ // in Goals Overview we list an overview for each goal....
+ $view->config->addTranslation('conversion_rate', Piwik::translate('Goals_ConversionRate'));
+
+ } elseif ($isEcommerceEnabled) {
+ // in Goals detail page...
+ $view->config->addSparklineMetric(array('revenue'), $order = 30);
+ }
+ }
+ } else if ($view->isViewDataTableId(Evolution::ID)) {
+ if (empty($view->config->columns_to_display)) {
+ $view->config->columns_to_display = array('nb_conversions');
+ }
+ }
+ }
+
public function configureReportMetadata(&$availableReports, $infos)
{
if (!$this->isEnabled()) {
diff --git a/plugins/Goals/Widgets.php b/plugins/Goals/Widgets.php
deleted file mode 100644
index 94d91bda5c..0000000000
--- a/plugins/Goals/Widgets.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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\Goals;
-
-use Piwik\Common;
-
-class Widgets extends \Piwik\Plugin\Widgets
-{
- protected $category = 'Goals_Goals';
-
- protected function init()
- {
- $this->addWidget('Goals_GoalsOverview', 'widgetGoalsOverview');
-
- $idSite = $this->getIdSite();
- $goals = API::getInstance()->getGoals($idSite);
-
- if (count($goals) > 0) {
- foreach ($goals as $goal) {
- $name = Common::sanitizeInputValue($goal['name']);
- $params = array('idGoal' => $goal['idgoal']);
-
- $this->addWidget($name, 'widgetGoalReport', $params);
- }
- }
- }
-
- private function getIdSite()
- {
- return Common::getRequestVar('idSite', null, 'int');
- }
-
-}
diff --git a/plugins/Goals/Widgets/AddNewGoal.php b/plugins/Goals/Widgets/AddNewGoal.php
new file mode 100644
index 0000000000..b692309b9d
--- /dev/null
+++ b/plugins/Goals/Widgets/AddNewGoal.php
@@ -0,0 +1,38 @@
+<?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\Goals\Widgets;
+
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugins\Goals\API;
+use Piwik\Widget\WidgetConfig;
+
+class AddNewGoal extends \Piwik\Widget\Widget
+{
+ public static function configure(WidgetConfig $config)
+ {
+ $idSite = Common::getRequestVar('idSite', null, 'int');
+ $goals = API::getInstance()->getGoals($idSite);
+
+ $config->setCategoryId('Goals_Goals');
+ $config->setSubcategoryId('Goals_AddNewGoal');
+ $config->setParameters(array('idGoal' => ''));
+ $config->setIsNotWidgetizable();
+
+ if (Piwik::isUserHasAdminAccess($idSite)) {
+ $config->setName('Goals_AddNewGoal');
+ } else {
+ $config->setName('Goals_CreateNewGOal');
+ }
+
+ if (count($goals) !== 0) {
+ $config->disable();
+ }
+ }
+}
diff --git a/plugins/Goals/Widgets/EditGoals.php b/plugins/Goals/Widgets/EditGoals.php
new file mode 100644
index 0000000000..d0bb52667c
--- /dev/null
+++ b/plugins/Goals/Widgets/EditGoals.php
@@ -0,0 +1,37 @@
+<?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\Goals\Widgets;
+
+use Piwik\Common;
+use Piwik\Piwik;
+use Piwik\Plugins\Goals\API;
+use Piwik\Widget\WidgetConfig;
+
+class EditGoals extends \Piwik\Widget\Widget
+{
+ public static function configure(WidgetConfig $config)
+ {
+ $idSite = Common::getRequestVar('idSite', null, 'int');
+ $goals = API::getInstance()->getGoals($idSite);
+
+ $config->setCategoryId('Goals_Goals');
+ $config->setSubcategoryId('Goals_ManageGoals');
+ $config->setIsNotWidgetizable();
+
+ if (Piwik::isUserHasAdminAccess($idSite)) {
+ $config->setName('Goals_ManageGoals');
+ } else {
+ $config->setName('Goals_CreateNewGOal');
+ }
+
+ if (count($goals) === 0) {
+ $config->disable();
+ }
+ }
+}
diff --git a/plugins/Goals/lang/en.json b/plugins/Goals/lang/en.json
index 0545d0640f..8820b333e7 100644
--- a/plugins/Goals/lang/en.json
+++ b/plugins/Goals/lang/en.json
@@ -36,6 +36,7 @@
"ConversionByTypeReportDocumentation": "This report provides detailed information about the goal performance (conversions, conversion rates and revenue per visit) for each of the categories available in the left panel. %s Please click on one of the categories to view the report. %s For more information, read the %sTracking Goals documentation%s",
"ConversionRate": "%s conversion rate",
"Conversions": "%s conversions",
+ "ConversionsDescription": "conversions",
"ConversionsOverview": "Conversions Overview",
"ConversionsOverviewBy": "Conversions overview by type of visit",
"DaysToConv": "Days to Conversion",
@@ -79,8 +80,8 @@
"NoGoalsNeedAccess": "Only an Administrator or a user with Super User access can manage Goals for a given website. Please ask your Piwik administrator to set up a Goal for your website. <br>Tracking Goals is a great way to help understand and maximize your website performance!",
"NeedAccess": "Only an Administrator or a user with Super User access can manage Goals for a given website.",
"Optional": "(optional)",
- "OverallConversionRate": "%s overall conversion rate (visits with a completed goal)",
- "OverallRevenue": "%s overall revenue",
+ "OverallConversionRate": "overall conversion rate (visits with a completed goal)",
+ "OverallRevenue": "overall revenue",
"PageTitle": "Page Title",
"Pattern": "Pattern",
"PluginDescription": "Create Goals and see detailed reports about your goal conversions: evolution over time, revenue per visit, conversions per referrer, per keyword, and more.",
diff --git a/plugins/Goals/templates/_titleAndEvolutionGraph.twig b/plugins/Goals/templates/_titleAndEvolutionGraph.twig
deleted file mode 100644
index 0a2fdc1e31..0000000000
--- a/plugins/Goals/templates/_titleAndEvolutionGraph.twig
+++ /dev/null
@@ -1,86 +0,0 @@
-<span data-graph-id="{{ nameGraphEvolution }}"></span>
-
-{% if displayFullReport or headline is defined %}
- <h2 piwik-enriched-headline
- {% if idGoal is defined and idGoal and goalName is defined and not ecommerce is defined %}
- edit-url="{{ linkTo({'module': 'Goals', 'action': 'manage', 'idGoal': idGoal})|e('html_attr') }}"
- feature-name="{{ 'Goals_Details'|translate|e('html_attr') }}"
- {% endif %}
- >{% if headline is defined %}{{ headline }}{% elseif goalName is defined %}{{ 'Goals_GoalX'|translate(goalName) }}{% else %}{{ 'General_EvolutionOverPeriod'|translate }}{% endif %}</h2>
-{% endif %}
-{{ graphEvolution|raw }}
-
-<div id='leftcolumn' style="clear:both;{% if not isWidget and ecommerce is defined %}width:33%;'{% endif %}">
- <div class="sparkline">{{ sparkline(urlSparklineConversions) }}
- {% if ecommerce is defined %}
- <strong>{{ nb_conversions }}</strong>
- {{ 'General_EcommerceOrders'|translate }}
- <img src='plugins/Morpheus/images/ecommerceOrder.gif'>
- {% else %}
- {{ 'Goals_Conversions'|translate("<strong>"~nb_conversions~"</strong>")|raw }}
- {% endif %}
- {% if goalAllowMultipleConversionsPerVisit is defined and goalAllowMultipleConversionsPerVisit %}
- ({{ 'General_NVisits'|translate("<strong>"~nb_visits_converted~"</strong>")|raw }})
- {% endif %}
- </div>
- {% if revenue != 0 or ecommerce is defined %}
- <div class="sparkline">
- {{ sparkline(urlSparklineRevenue) }}
- {% set revenue=revenue|money(idSite) %}
- {% if ecommerce is defined %}
- <strong>{{ revenue|raw }}</strong> {{ 'General_TotalRevenue'|translate }}
- {% else %}
- {{ 'Goals_OverallRevenue'|translate("<strong>"~revenue~"</strong>")|raw }}
- {% endif %}
- </div>
- {% endif %}
- {% if ecommerce is defined %}
- <div class="sparkline">{{ sparkline(urlSparklineAverageOrderValue) }}
- <strong>{{ avg_order_revenue|money(idSite)|raw }}</strong>
- {{ 'General_AverageOrderValue'|translate }}
- </div>
- {% endif %}
-
-</div>
-<div id='leftcolumn' {% if not isWidget and ecommerce is defined %}style='width:33%;'{% endif %}>
- <div class="sparkline">{{ sparkline(urlSparklineConversionRate) }}
- {% if ecommerce is defined %}
- {% set ecommerceOrdersText %}{{ 'General_EcommerceOrders'|translate }}{% endset %}
- {{ 'Goals_ConversionRate'|translate("<strong>"~conversion_rate~"</strong> "~ecommerceOrdersText)|raw }}
- {% else %}
- {{ 'Goals_OverallConversionRate'|translate("<strong>"~conversion_rate~"</strong>")|raw }}
- {% endif %}
- </div>
- {% if ecommerce is defined %}
- <div class="sparkline">{{ sparkline(urlSparklinePurchasedProducts) }}
- <strong>{{ items }}</strong> {{ 'General_PurchasedProducts'|translate }}</div>
- {% endif %}
-</div>
-{% if ecommerce is defined %}
- <div id='rightcolumn' {% if not isWidget %}style='width:30%;'{% endif %}>
- <div>
- <img src='plugins/Morpheus/images/ecommerceAbandonedCart.gif'> <em>{{ 'General_AbandonedCarts'|translate }}</em>
- </div>
-
- <div class="sparkline">
- {{ sparkline(cart_urlSparklineConversions) }}
- {% set ecommerceAbandonedCartsText %}{{ 'Goals_AbandonedCart'|translate }}{% endset %}
- <strong>{{ cart_nb_conversions }}</strong> {{ 'General_VisitsWith'|translate(ecommerceAbandonedCartsText) }}
- </div>
-
- <div class="sparkline">
- {{ sparkline(cart_urlSparklineRevenue) }}
- {% set revenue %}{{ cart_revenue|money(idSite)|raw }}{% endset %}
- {% set revenueText %}{{ 'General_ColumnRevenue'|translate }}{% endset %}
- <strong>{{ revenue }}</strong> {{ 'Goals_LeftInCart'|translate(revenueText) }}
- </div>
-
- <div class="sparkline">
- {{ sparkline(cart_urlSparklineConversionRate) }}
- <strong>{{ cart_conversion_rate }}</strong>
- {{ 'General_VisitsWith'|translate(ecommerceAbandonedCartsText) }}
- </div>
- </div>
-{% endif %}
-{% include "_sparklineFooter.twig" %}
-
diff --git a/plugins/Goals/templates/addNewGoal.twig b/plugins/Goals/templates/addNewGoal.twig
index a2b44b88e9..844892ecbc 100644
--- a/plugins/Goals/templates/addNewGoal.twig
+++ b/plugins/Goals/templates/addNewGoal.twig
@@ -1,5 +1,4 @@
{% if userCanEditGoals %}
- <h2 piwik-enriched-headline>{{ 'Goals_AddNewGoal'|translate }}</h2>
<p>{{ 'Goals_NewGoalIntro'|translate }}</p>
<p>{{ 'Goals_LearnMoreAboutGoalTrackingDocumentation'|translate("<a href='?module=Proxy&action=redirect&url=http://piwik.org/docs/tracking-goals-web-analytics/' target='_blank'>","</a>")|raw }}
{{ 'Goals_ManageGoalsOrCreateANewGoal'|translate("<a href='#module=Goals&action=editGoals'>","</a>")|raw }}
diff --git a/plugins/Goals/templates/conversionOverview.twig b/plugins/Goals/templates/conversionOverview.twig
new file mode 100644
index 0000000000..2697527eb7
--- /dev/null
+++ b/plugins/Goals/templates/conversionOverview.twig
@@ -0,0 +1,15 @@
+<ul class="ulGoalTopElements">
+ {% if topDimensions.country is defined %}
+ <li>{{ 'Goals_BestCountries'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.country} %}</li>
+ {% endif %}
+ {% if topDimensions.keyword is defined and topDimensions.keyword|length > 0 %}
+ <li>{{ 'Goals_BestKeywords'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.keyword} %}</li>
+ {% endif %}
+ {% if topDimensions.website is defined and topDimensions.website|length > 0 %}
+ <li>{{ 'Goals_BestReferrers'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.website} %}</li>
+ {% endif %}
+ <li>
+ {{ 'Goals_ReturningVisitorsConversionRateIs'|translate("<strong>"~conversion_rate_returning~"</strong>")|raw }}
+ , {{ 'Goals_NewVisitorsConversionRateIs'|translate("<strong>"~conversion_rate_new~"</strong>")|raw }}
+ </li>
+</ul><br style="clear:left"/> \ No newline at end of file
diff --git a/plugins/Goals/templates/editGoals.twig b/plugins/Goals/templates/editGoals.twig
index 76b64b9918..1bc8956511 100644
--- a/plugins/Goals/templates/editGoals.twig
+++ b/plugins/Goals/templates/editGoals.twig
@@ -1,7 +1,5 @@
{% if userCanEditGoals %}
- <h2 piwik-enriched-headline>{{ 'Goals_ManageGoals'|translate }}</h2>
-
{% include "@Goals/_addEditGoal.twig" %}
{% else %}
diff --git a/plugins/Goals/templates/getGoalReportView.twig b/plugins/Goals/templates/getGoalReportView.twig
deleted file mode 100644
index 2cb3b7f4d0..0000000000
--- a/plugins/Goals/templates/getGoalReportView.twig
+++ /dev/null
@@ -1,66 +0,0 @@
-<link rel="stylesheet" type="text/css" href="plugins/Goals/stylesheets/goals.css"/>
-{% include "@Goals/_titleAndEvolutionGraph.twig" | raw %}
-
-<div class="clear"></div>
-{% if nb_conversions > 0 %}
- <h2>{{ 'Goals_ConversionsOverview'|translate }}</h2>
- <ul class="ulGoalTopElements">
- {% if ecommerce is not defined %}
- {% if topDimensions.country is defined %}
- <li>{{ 'Goals_BestCountries'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.country} %}</li>
- {% endif %}
- {% if topDimensions.keyword is defined and topDimensions.keyword|length > 0 %}
- <li>{{ 'Goals_BestKeywords'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.keyword} %}</li>
- {% endif %}
- {% if topDimensions.website is defined and topDimensions.website|length > 0 %}
- <li>{{ 'Goals_BestReferrers'|translate }} {% include '@Goals/_listTopDimension.twig' with {'topDimension':topDimensions.website} %}</li>
- {% endif %}
- <li>
- {{ 'Goals_ReturningVisitorsConversionRateIs'|translate("<strong>"~conversion_rate_returning~"</strong>")|raw }}
- , {{ 'Goals_NewVisitorsConversionRateIs'|translate("<strong>"~conversion_rate_new~"</strong>")|raw }}
- </li>
- {% else %}
- <li>
- {{ 'General_ColumnRevenue'|translate }}: {{ revenue|money(idSite)|raw -}}
- {% if revenue_subtotal is not empty %},
- {{ 'General_Subtotal'|translate }}: {{ revenue_subtotal|money(idSite)|raw -}}
- {% endif %}
- {%- if revenue_tax is not empty -%},
- {{ 'General_Tax'|translate }}: {{ revenue_tax|money(idSite)|raw -}}
- {% endif %}
- {%- if revenue_shipping is not empty -%},
- {{ 'General_Shipping'|translate }}: {{ revenue_shipping|money(idSite)|raw -}}
- {% endif %}
- {%- if revenue_discount is not empty -%},
- {{ 'General_Discount'|translate }}: {{ revenue_discount|money(idSite)|raw -}}
- {% endif %}
- </li>
- {% endif %}
- </ul>
-{% endif %}
-
-<script type="text/javascript">
- $(document).ready(function () {
- $('.goalTopElement').tooltip({
- track: true,
- content: function () {
- return $(this).attr("title");
- },
- show: false,
- hide: false
- });
- });
-</script>
-
-{% if displayFullReport %}
- {% if nb_conversions > 0 or cart_nb_conversions is defined %}
- <h2 id='titleGoalsByDimension'>
- {% if idGoal is defined %}
- {{ 'Goals_GoalConversionsBy'|translate(goalName) }}
- {% else %}
- {{ 'Goals_ConversionsOverviewBy'|translate }}
- {% endif %}
- </h2>
- {{ goalReportsByDimension|raw }}
- {% endif %}
-{% endif %}
diff --git a/plugins/Goals/templates/getOverviewView.twig b/plugins/Goals/templates/getOverviewView.twig
deleted file mode 100644
index 909fd01711..0000000000
--- a/plugins/Goals/templates/getOverviewView.twig
+++ /dev/null
@@ -1,58 +0,0 @@
-<link rel="stylesheet" type="text/css" href="plugins/Goals/stylesheets/goals.css"/>
-
-{% include "@Goals/_titleAndEvolutionGraph.twig" %}
-{% set sum_nb_conversions=nb_conversions %}
-
-{% for goal in goalMetrics %}
- {% set nb_conversions=goal.nb_conversions %}
- {% set nb_visits_converted=goal.nb_visits_converted %}
- {% set conversion_rate=goal.conversion_rate %}
- {% set name=goal.name %}
- <div class="goalEntry" style="clear:both">
- <h2>
- <a href="javascript:broadcast.propagateAjax('module=Goals&action=goalReport&idGoal={{ goal.id }}')">
- {{ 'Goals_GoalX'|translate("'"~name~"'") }}
- </a>
- </h2>
-
- {% if not isWidget %}
- <div class="row">
- <div class="col-md-6">
- {% endif %}
-
- <div class="sparkline">{{ sparkline(goal.urlSparklineConversions) }}
- {{ 'Goals_Conversions'|translate("<strong>"~nb_conversions~"</strong>")|raw }}
- {% if goal.goalAllowMultipleConversionsPerVisit %}
- ({{ 'General_NVisits'|translate("<strong>"~nb_visits_converted~"</strong>") | raw }})
- {% endif %}
- </div>
-
- {% if not isWidget %}
- </div>
- <div class="col-md-6">
- {% endif %}
-
- <div class="sparkline">{{ sparkline(goal.urlSparklineConversionRate) }}
- {{ 'Goals_ConversionRate'|translate("<strong>"~conversion_rate~"</strong>")|raw }}
- </div>
-
- {% if not isWidget %}
- </div>
- </div>
- {% endif %}
-
- </div>
-{% endfor %}
-
-{% if displayFullReport %}
- {% if sum_nb_conversions != 0 %}
- <h2 id='titleGoalsByDimension'>
- {% if idGoal is defined %}
- {{ 'Goals_GoalConversionsBy'|translate(goalName) }}
- {% else %}
- {{ 'Goals_ConversionsOverviewBy'|translate }}
- {% endif %}
- </h2>
- {{ goalReportsByDimension|raw }}
- {% endif %}
-{% endif %}