From 532ec64534e993316296f1cc193a9247b5247eb7 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 9 Mar 2022 17:34:34 +1300 Subject: Rework to use a single goals visualisation and show goal metrics directly on the action page reports --- plugins/Goals/API.php | 130 ------------- plugins/Goals/Controller.php | 5 +- plugins/Goals/Goals.php | 9 +- plugins/Goals/Pages.php | 11 +- plugins/Goals/Reports/BasePages.php | 49 ----- plugins/Goals/Reports/GetPagesEntry.php | 61 ------ plugins/Goals/Reports/GetPagesEntryTitles.php | 61 ------ plugins/Goals/Reports/GetPagesTitles.php | 51 ------ plugins/Goals/Reports/GetPagesUrl.php | 51 ------ plugins/Goals/Visualizations/Goals.php | 173 ++++++++++++++--- plugins/Goals/Visualizations/GoalsEntryPages.php | 71 ------- plugins/Goals/Visualizations/GoalsPages.php | 74 -------- plugins/Goals/lang/en.json | 2 +- plugins/Goals/tests/System/TrackGoalsPagesTest.php | 16 +- ...Goals_pages__Actions.getEntryPageTitles_day.xml | 40 ++++ ...ckGoals_pages__Actions.getEntryPageUrls_day.xml | 41 +++++ ...trackGoals_pages__Actions.getPageTitles_day.xml | 117 ++++++++++++ ...t_trackGoals_pages__Actions.getPageUrls_day.xml | 121 ++++++++++++ ...kGoals_pages__Goals.getPagesEntryTitles_day.xml | 204 --------------------- ...t_trackGoals_pages__Goals.getPagesEntry_day.xml | 204 --------------------- ..._trackGoals_pages__Goals.getPagesTitles_day.xml | 199 -------------------- ...est_trackGoals_pages__Goals.getPagesUrl_day.xml | 199 -------------------- plugins/Goals/tests/UI/Goals_spec.js | 8 +- 23 files changed, 495 insertions(+), 1402 deletions(-) delete mode 100644 plugins/Goals/Reports/BasePages.php delete mode 100644 plugins/Goals/Reports/GetPagesEntry.php delete mode 100644 plugins/Goals/Reports/GetPagesEntryTitles.php delete mode 100644 plugins/Goals/Reports/GetPagesTitles.php delete mode 100644 plugins/Goals/Reports/GetPagesUrl.php delete mode 100644 plugins/Goals/Visualizations/GoalsEntryPages.php delete mode 100644 plugins/Goals/Visualizations/GoalsPages.php create mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageTitles_day.xml create mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageUrls_day.xml create mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageTitles_day.xml create mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageUrls_day.xml delete mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntryTitles_day.xml delete mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntry_day.xml delete mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesTitles_day.xml delete mode 100644 plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesUrl_day.xml (limited to 'plugins/Goals') diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index d3dd615509..c361ab323e 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -777,136 +777,6 @@ class API extends \Piwik\Plugin\API return $dataTable; } - /** - * Gets a DataTable that maps pages to the count of conversions that occurred on visits - * where the page was viewed before conversion for the specified site, date range, segment and goal. - * - * @param int $idSite The site to select data from. - * @param string $period The period type. - * @param string $date The date type. - * @param string|bool $segment The segment. - * @param int|bool $idGoal The id of the goal to get data for. If this is set to false, - * data for every goal that belongs to $idSite is returned. - * - * @return bool|DataTable - */ - public function getPagesUrl($idSite, $period, $date, $segment = false, $idGoal = false) - { - Piwik::checkUserHasViewAccess($idSite); - $dataTable = Archive::createDataTableFromArchive('Actions_actions_url', $idSite, $period, $date, $segment); - $this->applyPagesFilters($dataTable, $idGoal); - - return $dataTable; - } - - /** - * Gets a DataTable that maps page titles to the count of conversions that occurred on visits - * where the page was viewed before conversion for the specified site, date range, segment and goal. - * - * @param int $idSite The site to select data from. - * @param string $period The period type. - * @param string $date The date type. - * @param string|bool $segment The segment. - * @param int|bool $idGoal The id of the goal to get data for. If this is set to false, - * data for every goal that belongs to $idSite is returned. - * - * @return bool|DataTable - */ - public function getPagesTitles($idSite, $period, $date, $segment = false, $idGoal = false) - { - Piwik::checkUserHasViewAccess($idSite); - $dataTable = Archive::createDataTableFromArchive('Actions_actions', $idSite, $period, $date, $segment); - $this->applyPagesFilters($dataTable, $idGoal); - - return $dataTable; - } - - /** - * Apply datatable filters for page reports - * - * @param $dataTable - * @param $idGoal - * - * @return bool|DataTable - */ - private function applyPagesFilters($dataTable, $idGoal) - { - if ($dataTable) { - $dataTable->queueFilter('Piwik\Plugins\Goals\DataTable\Filter\CalculateConversionPageRate'); - $dataTable->queueFilter('ReplaceColumnNames'); - $dataTable->queueFilter('Piwik\Plugins\Goals\DataTable\Filter\RemoveUnusedGoalRevenueColumns'); - $colsToRemove = ['idaction', 'type', 'nb_conversions', 'revenue', 'nb_visits']; - $dataTable->queueFilter('ColumnDelete', array($colsToRemove)); - $nestedColsToRemove = ['nb_conversions', 'nb_visits_converted', 'nb_conv_pages_before', 'nb_conversions_page_uniq']; - $dataTable->queueFilter('ColumnDelete', array($nestedColsToRemove, [], false, true)); - } - - return $dataTable; - } - - /** - * Gets a DataTable that maps entry pages to the count of conversions that occurred on visits that started on - * each entry page and resulted in a conversion, for the specified site, date range, segment and goal. - * - * @param int $idSite The site to select data from. - * @param string $period The period type. - * @param string $date The date type. - * @param string|bool $segment The segment. - * @param int|bool $idGoal The id of the goal to get data for. If this is set to false, - * data for every goal that belongs to $idSite is returned. - * - * @return bool|DataTable - */ - public function getPagesEntry($idSite, $period, $date, $segment = false, $idGoal = false) - { - Piwik::checkUserHasViewAccess($idSite); - $dataTable = Archive::createDataTableFromArchive('Actions_actions_url', $idSite, $period, $date, $segment); - $this->applyPagesEntryFilters($dataTable); - - return $dataTable; - } - - /** - * Gets a DataTable that maps entry pages by titles to the count of conversions that occurred on visits that started - * on each entry page and resulted in a conversion, for the specified site, date range, segment and goal. - * - * @param int $idSite The site to select data from. - * @param string $period The period type. - * @param string $date The date type. - * @param string|bool $segment The segment. - * @param int|bool $idGoal The id of the goal to get data for. If this is set to false, - * data for every goal that belongs to $idSite is returned. - * - * @return bool|DataTable - */ - public function getPagesEntryTitles($idSite, $period, $date, $segment = false, $idGoal = false) - { - Piwik::checkUserHasViewAccess($idSite); - $dataTable = Archive::createDataTableFromArchive('Actions_actions', $idSite, $period, $date, $segment); - $this->applyPagesEntryFilters($dataTable); - - return $dataTable; - } - - /** - * Apply datatable filters for entry page reports - * - * @param $dataTable - * - * @return bool|DataTable - */ - private function applyPagesEntryFilters($dataTable) - { - if ($dataTable) { - $dataTable->queueFilter('ReplaceColumnNames'); - $dataTable->queueFilter('Piwik\Plugins\Goals\DataTable\Filter\RemoveUnusedGoalRevenueColumns'); - $dataTable->queueFilter('ColumnDelete', - array($columnsToRemove = ['idaction', 'nb_visits', 'entry_nb_uniq_visitors', 'revenue', 'nb_conversions'])); - } - - return $dataTable; - } - /** * Enhances the dataTable with Items attributes found in the Custom Variables report. * diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 65496bad69..6a65135230 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -289,7 +289,7 @@ class Controller extends \Piwik\Plugin\Controller } $topDimensionsToLoad += array( - 'entry_page' => 'Goals.getPagesEntry', + 'entry_page' => 'Actions.getEntryPageUrls', ); $topDimensions = array(); @@ -301,7 +301,8 @@ class Controller extends \Piwik\Plugin\Controller &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)); + "&filter_limit=" . (self::COUNT_TOP_ROWS_TO_DISPLAY + 2). + ($dimensionName == 'entry_page' ? '&$includeGoals=1' : '')); $datatable = $request->process(); $topDimension = array(); $count = 0; diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 446d4d258e..df653821f2 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -305,13 +305,10 @@ class Goals extends \Piwik\Plugin 'name' => $report->getName(), 'module' => $report->getModule(), 'action' => $report->getAction(), - 'parameters' => $report->getParameters() + 'parameters' => $report->getParameters(), + 'order' => $report->getOrder() ); - if ($report instanceof BasePages) { - $r['viewDataTable'] = $report->getDefaultTypeViewDataTable(); - } - $reportsWithGoals[] = $r; } } @@ -395,6 +392,6 @@ class Goals extends \Piwik\Plugin $translationKeys[] = 'Goals_TimeInMinutes'; $translationKeys[] = 'Goals_Pattern'; $translationKeys[] = 'Goals_ClickToViewThisGoal'; - $translationKeys[] = 'Goals_CategoryTextPages'; + $translationKeys[] = 'Goals_CategoryTextGeneral_Actions'; } } diff --git a/plugins/Goals/Pages.php b/plugins/Goals/Pages.php index cb22954dda..cef5939b83 100644 --- a/plugins/Goals/Pages.php +++ b/plugins/Goals/Pages.php @@ -275,11 +275,12 @@ class Pages $categoryText = $translationHelper->translateGoalMetricCategory($category); } - foreach ($reports as $report) { + // Sort reports in each category to respect the report order property + uasort($reports, function ($a, $b) { + return $a['order'] <=> $b['order']; + }); - if ($report['name'] === Piwik::translate('Goals_EntryPagesTitles')) { - continue; - } + foreach ($reports as $report) { $order++; @@ -329,7 +330,7 @@ class Pages if (is_null($order)) { $order = array( 'Referrers_Referrers', - 'Pages', + 'General_Actions', 'General_Visit', 'General_Visitors', 'VisitsSummary_VisitsSummary', diff --git a/plugins/Goals/Reports/BasePages.php b/plugins/Goals/Reports/BasePages.php deleted file mode 100644 index 495e98498e..0000000000 --- a/plugins/Goals/Reports/BasePages.php +++ /dev/null @@ -1,49 +0,0 @@ -categoryId = 'Pages'; - $this->hasGoalMetrics = true; - $this->parameters = null; - $this->orderGoal = 51; - } - - public function configureReportMetadata(&$availableReports, $infos) - { - if (!$this->isEnabled()) { - return; - } - - if (null !== $this->getIdSiteFromInfos($infos)) { - parent::configureReportMetadata($availableReports, $infos); - } - - $name = $this->name; - - $this->addReportMetadataForEachGoal($availableReports, $infos, function ($goal) use ($name) { - return $goal['name'] . ' - ' . $name; - }); - } - -} diff --git a/plugins/Goals/Reports/GetPagesEntry.php b/plugins/Goals/Reports/GetPagesEntry.php deleted file mode 100644 index 5ed0b766ba..0000000000 --- a/plugins/Goals/Reports/GetPagesEntry.php +++ /dev/null @@ -1,61 +0,0 @@ -name = Piwik::translate('Goals_EntryPages'); - $this->documentation = Piwik::translate('Goals_EntryPagesReportDocumentation'); - $this->dimension = new EntryPageUrl(); - $this->metrics = array( 'nb_conversions_entry', 'nb_visits_converted', 'revenue_entry', 'entry_nb_visits'); - $this->order = 2; - } - - public function configureView(ViewDataTable $view) - { - - $view->config->show_exclude_low_population = false; - - if ($view->isViewDataTableId(HtmlTable::ID)) { - $view->config->disable_subtable_when_show_goals = true; - } - - $view->requestConfig->filter_sort_column = 'entry_nb_visits'; - $view->requestConfig->filter_sort_order = 'asc'; - $view->requestConfig->filter_limit = 25; - - $view->config->addTranslations(array('label' => $this->dimension->getName(), - 'entry_nb_visits' => Piwik::translate('General_ColumnEntrances'))); - - } - - public function getDefaultTypeViewDataTable() - { - return GoalsEntryPages::ID; - } - - public function getRelatedReports() - { - return array( - ReportsProvider::factory('Goals', 'getPagesEntryTitles'), - ); - } - -} diff --git a/plugins/Goals/Reports/GetPagesEntryTitles.php b/plugins/Goals/Reports/GetPagesEntryTitles.php deleted file mode 100644 index ecf637a5f7..0000000000 --- a/plugins/Goals/Reports/GetPagesEntryTitles.php +++ /dev/null @@ -1,61 +0,0 @@ -name = Piwik::translate('Goals_EntryPagesTitles'); - $this->documentation = Piwik::translate('Goals_EntryPagesReportDocumentation'); - $this->dimension = new EntryPageUrl(); - $this->metrics = array( 'nb_conversions_entry', 'nb_visits_converted', 'revenue_entry', 'entry_nb_visits'); - $this->order = 4; - } - - public function configureView(ViewDataTable $view) - { - - $view->config->show_exclude_low_population = false; - - if ($view->isViewDataTableId(HtmlTable::ID)) { - $view->config->disable_subtable_when_show_goals = true; - } - - $view->requestConfig->filter_sort_column = 'entry_nb_visits'; - $view->requestConfig->filter_sort_order = 'asc'; - $view->requestConfig->filter_limit = 25; - - $view->config->addTranslations(array('label' => $this->dimension->getName(), - 'entry_nb_visits' => Piwik::translate('General_ColumnEntrances'))); - - } - - public function getDefaultTypeViewDataTable() - { - return GoalsEntryPages::ID; - } - - public function getRelatedReports() - { - return array( - ReportsProvider::factory('Goals', 'getPagesEntry'), - ); - } - -} diff --git a/plugins/Goals/Reports/GetPagesTitles.php b/plugins/Goals/Reports/GetPagesTitles.php deleted file mode 100644 index c3f63d9d4b..0000000000 --- a/plugins/Goals/Reports/GetPagesTitles.php +++ /dev/null @@ -1,51 +0,0 @@ -name = Piwik::translate('Goals_PageTitles'); - $this->documentation = Piwik::translate('Goals_PageTitlesReportDocumentation'); - $this->dimension = new PageTitle(); - $this->order = 3; - } - - public function configureView(ViewDataTable $view) - { - - $view->config->show_exclude_low_population = false; - - if ($view->isViewDataTableId(HtmlTable::ID)) { - $view->config->disable_subtable_when_show_goals = true; - } - - $view->requestConfig->filter_sort_column = 'nb_hits'; - $view->requestConfig->filter_sort_order = 'asc'; - $view->requestConfig->filter_limit = 25; - - $view->config->addTranslations(array('label' => $this->dimension->getName(), - 'nb_hits' => Piwik::translate('General_ColumnUniquePageviews'))); - } - - public function getDefaultTypeViewDataTable() - { - return GoalsPages::ID; - } - -} diff --git a/plugins/Goals/Reports/GetPagesUrl.php b/plugins/Goals/Reports/GetPagesUrl.php deleted file mode 100644 index bcbbf2a8c3..0000000000 --- a/plugins/Goals/Reports/GetPagesUrl.php +++ /dev/null @@ -1,51 +0,0 @@ -name = Piwik::translate('General_Pages'); - $this->documentation = Piwik::translate('Goals_PagesReportDocumentation'); - $this->dimension = new PageUrl(); - $this->order = 1; - } - - public function configureView(ViewDataTable $view) - { - - $view->config->show_exclude_low_population = false; - - if ($view->isViewDataTableId(HtmlTable::ID)) { - $view->config->disable_subtable_when_show_goals = true; - } - - $view->requestConfig->filter_sort_column = 'nb_hits'; - $view->requestConfig->filter_sort_order = 'asc'; - $view->requestConfig->filter_limit = 25; - - $view->config->addTranslations(array('label' => $this->dimension->getName(), - 'nb_hits' => Piwik::translate('General_ColumnUniquePageviews'))); - } - - public function getDefaultTypeViewDataTable() - { - return GoalsPages::ID; - } - -} diff --git a/plugins/Goals/Visualizations/Goals.php b/plugins/Goals/Visualizations/Goals.php index cc49507d74..5d6ce9a5f8 100644 --- a/plugins/Goals/Visualizations/Goals.php +++ b/plugins/Goals/Visualizations/Goals.php @@ -30,8 +30,27 @@ class Goals extends HtmlTable const FOOTER_ICON = 'icon-goal'; const FOOTER_ICON_TITLE = 'General_DisplayTableWithGoalMetrics'; + const GOALS_DISPLAY_NORMAL = 0; + const GOALS_DISPLAY_PAGES = 1; + const GOALS_DISPLAY_ENTRY_PAGES = 2; + + private $displayType = self::GOALS_DISPLAY_NORMAL; + public function beforeLoadDataTable() { + // Check if one of the pages display types should be used + $requestMethod = $this->requestConfig->getApiModuleToRequest().'.'.$this->requestConfig->getApiMethodToRequest(); + if (in_array($requestMethod, ['Actions.getPageUrls', 'Actions.getPageTitles'])) { + $this->displayType = self::GOALS_DISPLAY_PAGES; + $this->requestConfig->request_parameters_to_modify['includeGoals'] = true; + $this->requestConfig->request_parameters_to_modify['idGoal'] = -3; + + } else if (in_array($requestMethod, ['Actions.getEntryPageUrls', 'Actions.getEntryPageTitles'])) { + $this->displayType = self::GOALS_DISPLAY_ENTRY_PAGES; + $this->requestConfig->request_parameters_to_modify['includeGoals'] = true; + $this->requestConfig->request_parameters_to_modify['idGoal'] = -4; + } + parent::beforeLoadDataTable(); $this->config->show_totals_row = false; @@ -51,7 +70,6 @@ class Goals extends HtmlTable $this->config->datatable_css_class = 'dataTableVizGoals'; $this->config->show_exclude_low_population = true; - $this->config->metrics_documentation['nb_visits'] = Piwik::translate('Goals_ColumnVisits'); if (1 == Common::getRequestVar('documentationForGoalsPage', 0, 'int')) { // TODO: should not use query parameter @@ -59,6 +77,21 @@ class Goals extends HtmlTable array('
', '
', '', '')); } + if ($this->displayType == self::GOALS_DISPLAY_NORMAL) { + $this->config->metrics_documentation['nb_visits'] = Piwik::translate('Goals_ColumnVisits'); + } + + if ($this->displayType == self::GOALS_DISPLAY_PAGES) { + $this->removeExcludedColumns(); + $this->config->addTranslation('nb_hits', Piwik::translate('General_ColumnUniquePageviews')); + $this->config->metrics_documentation['nb_hits'] = Piwik::translate('General_ColumnUniquePageviewsDocumentation'); + } + + if ($this->displayType == self::GOALS_DISPLAY_ENTRY_PAGES) { + $this->removeExcludedColumns(); + $this->config->metrics_documentation['entry_nb_visits'] = Piwik::translate('General_ColumnEntrancesDocumentation'); + } + parent::beforeRender(); } @@ -119,46 +152,138 @@ class Goals extends HtmlTable $allGoals = $this->getGoals($idSite); // set view properties - $this->config->columns_to_display = array('label', 'nb_visits'); + if ($this->displayType == self::GOALS_DISPLAY_NORMAL) { + $this->config->columns_to_display = array('label', 'nb_visits'); - foreach ($allGoals as $goal) { - $column = "goal_{$goal['idgoal']}_conversion_rate"; - $this->config->columns_to_display[] = $column; + foreach ($allGoals as $goal) { + $column = "goal_{$goal['idgoal']}_conversion_rate"; + $this->config->columns_to_display[] = $column; + } + + $this->config->columns_to_display[] = 'revenue_per_visit'; + } + + if ($this->displayType == self::GOALS_DISPLAY_PAGES) { + $this->config->columns_to_display = array('label', 'nb_hits'); + $goalColumnTemplates = array( + 'goal_%s_nb_conversions_attrib', + 'goal_%s_revenue_attrib', + 'goal_%s_nb_conversions_page_rate', + ); + + // set columns to display (columns of same type but different goals will be next to each other, + // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) + foreach ($allGoals as $goal) { + foreach ($goalColumnTemplates as $columnTemplate) { + $this->config->columns_to_display[] = sprintf($columnTemplate, $goal['idgoal']); + } + } + } + + if ($this->displayType == self::GOALS_DISPLAY_ENTRY_PAGES) { + $this->config->columns_to_display = array('label', 'entry_nb_visits'); + + $goalColumnTemplates = array( + 'goal_%s_nb_conversions_entry', + 'goal_%s_nb_conversions_entry_rate', + 'goal_%s_revenue_entry', + 'goal_%s_revenue_per_entry', + ); + + // set columns to display (columns of same type but different goals will be next to each other, + // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) + foreach ($allGoals as $goal) { + foreach ($goalColumnTemplates as $columnTemplate) { + $this->config->columns_to_display[] = sprintf($columnTemplate, $goal['idgoal']); + } + } } - $this->config->columns_to_display[] = 'revenue_per_visit'; } protected function setPropertiesForGoals($idSite, $idGoals) { $allGoals = $this->getGoals($idSite); - if ('all' == $idGoals) { - $idGoals = array_keys($allGoals); - } else { - // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) - $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions'; - $this->requestConfig->filter_sort_order = 'desc'; + if ($this->displayType == self::GOALS_DISPLAY_NORMAL) { + if ('all' == $idGoals) { + $idGoals = array_keys($allGoals); + } else { + // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) + $this->requestConfig->filter_sort_column = 'goal_'.reset($idGoals).'_nb_conversions'; + $this->requestConfig->filter_sort_order = 'desc'; + } + + $this->config->columns_to_display = array('label', 'nb_visits'); + + $goalColumnTemplates = array( + 'goal_%s_nb_conversions', + 'goal_%s_conversion_rate', + 'goal_%s_revenue', + 'goal_%s_revenue_per_visit', + ); + + // set columns to display (columns of same type but different goals will be next to each other, + // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) + foreach ($goalColumnTemplates as $columnTemplate) { + foreach ($idGoals as $idGoal) { + $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); + } + } + + $this->config->columns_to_display[] = 'revenue_per_visit'; } - $this->config->columns_to_display = array('label', 'nb_visits'); + if ($this->displayType == self::GOALS_DISPLAY_PAGES) { + if ('all' === $idGoals) { + $idGoals = array_keys($allGoals); + $this->requestConfig->filter_sort_column = 'nb_hits'; + } else { + // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) + $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions_attrib'; + } + $this->requestConfig->filter_sort_order = 'desc'; + + $this->config->columns_to_display = array('label', 'nb_hits'); + $goalColumnTemplates = array( + 'goal_%s_nb_conversions_attrib', + 'goal_%s_revenue_attrib', + 'goal_%s_nb_conversions_page_rate', + ); - $goalColumnTemplates = array( - 'goal_%s_nb_conversions', - 'goal_%s_conversion_rate', - 'goal_%s_revenue', - 'goal_%s_revenue_per_visit', - ); + // set columns to display (columns of same type but different goals will be next to each other, + // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) + foreach ($idGoals as $idGoal) { + foreach ($goalColumnTemplates as $columnTemplate) { + $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); + } + } + } + + if ($this->displayType == self::GOALS_DISPLAY_ENTRY_PAGES) { + if ('all' === $idGoals) { + $idGoals = array_keys($allGoals); + $this->requestConfig->filter_sort_column = 'entry_nb_visits'; + } else { + // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) + $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions_entry'; + } + $this->requestConfig->filter_sort_order = 'desc'; + $this->config->columns_to_display = array('label', 'entry_nb_visits'); + $goalColumnTemplates = array( + 'goal_%s_nb_conversions_entry', + 'goal_%s_nb_conversions_entry_rate', + 'goal_%s_revenue_entry', + 'goal_%s_revenue_per_entry', + ); - // set columns to display (columns of same type but different goals will be next to each other, - // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) - foreach ($goalColumnTemplates as $columnTemplate) { foreach ($idGoals as $idGoal) { - $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); + foreach ($goalColumnTemplates as $columnTemplate) { + $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); + } } } - $this->config->columns_to_display[] = 'revenue_per_visit'; } protected $goalsForCurrentSite = null; diff --git a/plugins/Goals/Visualizations/GoalsEntryPages.php b/plugins/Goals/Visualizations/GoalsEntryPages.php deleted file mode 100644 index 94817d4fa1..0000000000 --- a/plugins/Goals/Visualizations/GoalsEntryPages.php +++ /dev/null @@ -1,71 +0,0 @@ -removeExcludedColumns(); - $this->config->metrics_documentation['entry_nb_visits'] = Piwik::translate('General_ColumnEntrancesDocumentation'); - parent::beforeRender(); - } - - protected function setPropertiesForGoalsOverview($idSite) - { - $allGoals = $this->getGoals($idSite); - - // set view properties - $this->config->columns_to_display = array('label', 'entry_nb_visits'); - - foreach ($allGoals as $goal) { - $column = "goal_{$goal['idgoal']}_nb_conversions_entry_rate"; - $this->config->columns_to_display[] = $column; - } - - $this->config->columns_to_display[] = 'revenue_per_entry'; - } - - protected function setPropertiesForGoals($idSite, $idGoals) - { - $allGoals = $this->getGoals($idSite); - - if ('all' === $idGoals) { - $idGoals = array_keys($allGoals); - $this->requestConfig->filter_sort_column = 'entry_nb_visits'; - } else { - // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) - $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions_entry'; - } - $this->requestConfig->filter_sort_order = 'desc'; - - $this->config->columns_to_display = array('label', 'entry_nb_visits'); - - $goalColumnTemplates = array( - 'goal_%s_nb_conversions_entry', - 'goal_%s_nb_conversions_entry_rate', - 'goal_%s_revenue_entry', - 'goal_%s_revenue_per_entry', - ); - - foreach ($idGoals as $idGoal) { - foreach ($goalColumnTemplates as $columnTemplate) { - $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); - } - } - } - -} diff --git a/plugins/Goals/Visualizations/GoalsPages.php b/plugins/Goals/Visualizations/GoalsPages.php deleted file mode 100644 index 38a3fc8fef..0000000000 --- a/plugins/Goals/Visualizations/GoalsPages.php +++ /dev/null @@ -1,74 +0,0 @@ -removeExcludedColumns(); - $this->config->addTranslation('nb_hits', Piwik::translate('General_ColumnUniquePageviews')); - $this->config->metrics_documentation['nb_hits'] = Piwik::translate('General_ColumnUniquePageviewsDocumentation'); - parent::beforeRender(); - } - - protected function setPropertiesForGoalsOverview($idSite) - { - $allGoals = $this->getGoals($idSite); - - // set view properties - $this->config->columns_to_display = array('label', 'nb_hits'); - - foreach ($allGoals as $goal) { - $column = "goal_{$goal['idgoal']}_nb_conversions_page_rate"; - $this->config->columns_to_display[] = $column; - } - - } - - protected function setPropertiesForGoals($idSite, $idGoals) - { - - $allGoals = $this->getGoals($idSite); - - if ('all' === $idGoals) { - $idGoals = array_keys($allGoals); - $this->requestConfig->filter_sort_column = 'nb_hits'; - } else { - // only sort by a goal's conversions if not showing all goals (for FULL_REPORT) - $this->requestConfig->filter_sort_column = 'goal_' . reset($idGoals) . '_nb_conversions_attrib'; - } - $this->requestConfig->filter_sort_order = 'desc'; - - $this->config->columns_to_display = array('label', 'nb_hits'); - - $goalColumnTemplates = array( - 'goal_%s_nb_conversions_attrib', - 'goal_%s_revenue_attrib', - 'goal_%s_nb_conversions_page_rate', - ); - - // set columns to display (columns of same type but different goals will be next to each other, - // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) - foreach ($idGoals as $idGoal) { - foreach ($goalColumnTemplates as $columnTemplate) { - $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); - } - } - - } - -} diff --git a/plugins/Goals/lang/en.json b/plugins/Goals/lang/en.json index d7f7f83086..36b81f0b56 100644 --- a/plugins/Goals/lang/en.json +++ b/plugins/Goals/lang/en.json @@ -16,7 +16,7 @@ "CategoryTextReferrers_Referrers": "Referrers", "CategoryTextVisitsSummary_VisitsSummary": "User attribute", "CategoryTextDevicesDetection_DevicesDetection": "Devices", - "CategoryTextPages": "Pages", + "CategoryTextGeneral_Actions": "Pages", "CategoryTextGeneral_Visit": "engagement", "ClickOutlink": "Click on a Link to an external website", "SendEvent": "Send an event", diff --git a/plugins/Goals/tests/System/TrackGoalsPagesTest.php b/plugins/Goals/tests/System/TrackGoalsPagesTest.php index 916d77c4dd..63044fbcb5 100644 --- a/plugins/Goals/tests/System/TrackGoalsPagesTest.php +++ b/plugins/Goals/tests/System/TrackGoalsPagesTest.php @@ -34,12 +34,16 @@ class TrackGoalsPagesTest extends SystemTestCase public function getApiForTesting() { return [ - ['Goals.getPagesUrl', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, 'idGoal' => 1]], - ['Goals.getPagesTitles', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, 'idGoal' => 1]], - ['Goals.getPagesEntry', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, 'idGoal' => 1, - 'otherRequestParameters' => ['filter_update_columns_when_show_all_goals' => 1]]], - ['Goals.getPagesEntryTitles', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, 'idGoal' => 1, - 'otherRequestParameters' => ['filter_update_columns_when_show_all_goals' => 1]]] + ['Actions.getPageUrls', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, + 'idGoal' => 1, 'includeGoals' => 1]], + ['Actions.getPageTitles', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, + 'idGoal' => 1, 'includeGoals' => 1]], + ['Actions.getEntryPageUrls', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, + 'idGoal' => 1, 'includeGoals' => 1, 'otherRequestParameters' => + ['filter_update_columns_when_show_all_goals' => 1]]], + ['Actions.getEntryPageTitles', ['idSite' => self::$fixture->idSite, 'date' => self::$fixture->dateTime, + 'idGoal' => 1, 'includeGoals' => 1, 'otherRequestParameters' => + ['filter_update_columns_when_show_all_goals' => 1]]] ]; } diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageTitles_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageTitles_day.xml new file mode 100644 index 0000000000..37c54238f6 --- /dev/null +++ b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageTitles_day.xml @@ -0,0 +1,40 @@ + + + + + 3 + 3 + 4 + 1440 + 0 + 0 + + + 3 + 3 + 10 + 2525 + 0 + + + 3 + 30 + 6 + 1 + 0 + 2 + 10 + 20 + 0.667 + 6.667 + 2 + + + 0 + 0 + 360 + 0% + 0% + entryPageTitle==Page%2BA + + \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageUrls_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageUrls_day.xml new file mode 100644 index 0000000000..9114308c5e --- /dev/null +++ b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getEntryPageUrls_day.xml @@ -0,0 +1,41 @@ + + + + + 3 + 3 + 4 + 1440 + 0 + 0 + + + 3 + 3 + 10 + 2525 + 0 + + + 3 + 30 + 6 + 1 + 0 + 2 + 10 + 20 + 0.667 + 6.667 + 2 + + + 0 + 0 + 360 + 0% + 0% + http://example.org/page_A + entryPageUrl==http%253A%252F%252Fexample.org%252Fpage_A + + \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageTitles_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageTitles_day.xml new file mode 100644 index 0000000000..96ad1c2c85 --- /dev/null +++ b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageTitles_day.xml @@ -0,0 +1,117 @@ + + + + + 3 + 3 + 4 + 1440 + 0 + 0 + + + 3 + 3 + 10 + 2525 + 0 + + + 3 + 30 + 6 + 1 + 0 + 2 + 10 + 20 + 0.667 + 6.667 + 2 + + + 0 + 0 + 360 + 0% + 0% + pageTitle==Page%2BA + + + + 2 + 2 + 2 + 0 + 0 + 0 + + + 2 + 2 + + + 2 + 20 + 6 + 0.75 + 0 + 2 + 7.5 + + + 0 + 0 + 0 + 0% + 100% + pageTitle==Page%2BC + + + + 1 + 1 + 1 + 360 + 0 + 0 + + + + + 1 + 10 + 4 + 0.25 + 0 + 1 + 2.5 + + + 0 + 0 + 360 + 0% + 0% + pageTitle==Page%2BB + + + + 1 + 1 + 1 + 0 + 0 + 0 + + + 1 + 1 + 0 + 0 + 0 + 0% + 100% + pageTitle==Page%2BD + + \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageUrls_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageUrls_day.xml new file mode 100644 index 0000000000..76810041d6 --- /dev/null +++ b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Actions.getPageUrls_day.xml @@ -0,0 +1,121 @@ + + + + + 3 + 3 + 4 + 1440 + 0 + 0 + + + 3 + 3 + 10 + 2525 + 0 + + + 3 + 30 + 6 + 1 + 0 + 2 + 10 + 20 + 0.667 + 6.667 + 2 + + + 0 + 0 + 360 + 0% + 0% + http://example.org/page_A + pageUrl==http%253A%252F%252Fexample.org%252Fpage_A + + + + 2 + 2 + 2 + 0 + 0 + 0 + + + 2 + 2 + + + 2 + 20 + 6 + 0.75 + 0 + 2 + 7.5 + + + 0 + 0 + 0 + 0% + 100% + http://example.org/page_C + pageUrl==http%253A%252F%252Fexample.org%252Fpage_C + + + + 1 + 1 + 1 + 360 + 0 + 0 + + + + + 1 + 10 + 4 + 0.25 + 0 + 1 + 2.5 + + + 0 + 0 + 360 + 0% + 0% + http://example.org/page_B + pageUrl==http%253A%252F%252Fexample.org%252Fpage_B + + + + 1 + 1 + 1 + 0 + 0 + 0 + + + 1 + 1 + 0 + 0 + 0 + 0% + 100% + http://example.org/page_D + pageUrl==http%253A%252F%252Fexample.org%252Fpage_D + + \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntryTitles_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntryTitles_day.xml deleted file mode 100644 index 1fcc1b7037..0000000000 --- a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntryTitles_day.xml +++ /dev/null @@ -1,204 +0,0 @@ - - - - - 3 - 4 - 1440 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 3 - 10 - 2525 - 0 - - - 3 - 30 - 6 - 1 - 0 - 2 - 10 - 20 - 0.667 - 6.667 - 2 - - - Page A - - - - 2 - 2 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 2 - 2 - - - 2 - 20 - 6 - 0.75 - 0 - 2 - 7.5 - - - Page C - - - - 1 - 1 - 360 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - - - 1 - 10 - 4 - 0.25 - 0 - 1 - 2.5 - - - Page B - - - - 1 - 1 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 1 - 1 - Page D - - \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntry_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntry_day.xml deleted file mode 100644 index 1af527fadc..0000000000 --- a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesEntry_day.xml +++ /dev/null @@ -1,204 +0,0 @@ - - - - - 3 - 4 - 1440 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 3 - 10 - 2525 - 0 - - - 3 - 30 - 6 - 1 - 0 - 2 - 10 - 20 - 0.667 - 6.667 - 2 - - - http://example.org/page_A - - - - 2 - 2 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 2 - 2 - - - 2 - 20 - 6 - 0.75 - 0 - 2 - 7.5 - - - http://example.org/page_C - - - - 1 - 1 - 360 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - - - 1 - 10 - 4 - 0.25 - 0 - 1 - 2.5 - - - http://example.org/page_B - - - - 1 - 1 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 1 - 1 - http://example.org/page_D - - \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesTitles_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesTitles_day.xml deleted file mode 100644 index f9358cc8c7..0000000000 --- a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesTitles_day.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - 3 - 4 - 1440 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 3 - 3 - 10 - 2525 - 0 - - - 30 - 1 - 1 - 10 - 20 - 0.667 - 6.667 - 2 - - - 1 - Page A - - - - 2 - 2 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 2 - 2 - - - 20 - 0.75 - 1 - 7.5 - - - 1 - Page C - - - - 1 - 1 - 360 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - - - 10 - 0.25 - 0.5 - 2.5 - - - 0.5 - Page B - - - - 1 - 1 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 1 - 1 - Page D - - \ No newline at end of file diff --git a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesUrl_day.xml b/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesUrl_day.xml deleted file mode 100644 index be95cd7749..0000000000 --- a/plugins/Goals/tests/System/expected/test_trackGoals_pages__Goals.getPagesUrl_day.xml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - 3 - 4 - 1440 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 3 - 3 - 10 - 2525 - 0 - - - 30 - 1 - 1 - 10 - 20 - 0.667 - 6.667 - 2 - - - 1 - http://example.org/page_A - - - - 2 - 2 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 2 - 2 - - - 20 - 0.75 - 1 - 7.5 - - - 1 - http://example.org/page_C - - - - 1 - 1 - 360 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - - - 10 - 0.25 - 0.5 - 2.5 - - - 0.5 - http://example.org/page_B - - - - 1 - 1 - 0 - 0 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0.0000 - 0 - - - 0 - 0 - - - 1 - 1 - http://example.org/page_D - - \ No newline at end of file diff --git a/plugins/Goals/tests/UI/Goals_spec.js b/plugins/Goals/tests/UI/Goals_spec.js index dd1ab7e3cd..6b25a29237 100644 --- a/plugins/Goals/tests/UI/Goals_spec.js +++ b/plugins/Goals/tests/UI/Goals_spec.js @@ -23,7 +23,7 @@ describe("Goals", function () { it('should show goals by page', async function() { await page.evaluate(function(){ - $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(2)').click(); + $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(1)').click(); }); await page.waitForSelector('.dimensionReport'); @@ -36,7 +36,7 @@ describe("Goals", function () { it('should show goals by page titles', async function() { await page.evaluate(function(){ - $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(4)').click(); + $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(3)').click(); }); await page.waitForSelector('.dimensionReport'); @@ -49,7 +49,7 @@ describe("Goals", function () { it('should show goals by entry page', async function() { await page.evaluate(function(){ - $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(3)').click(); + $('div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(2)').click(); }); await page.waitForSelector('.dimensionReport'); @@ -62,7 +62,7 @@ describe("Goals", function () { it('should show goals by entry page titles', async function() { await page.evaluate(function(){ - $('.datatableRelatedReports > ul:nth-child(1) > li:nth-child(2) > span:nth-child(1)').click(); + $('.div.dimensionCategory:nth-child(2) > ul:nth-child(1) > li:nth-child(4)').click(); }); await page.waitForSelector('.dimensionReport'); -- cgit v1.2.3