public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $idSite = Common::getRequestVar('idSite', 0, 'int'); if (empty($idSite)) { return; } $goals = $this->getGoals(); $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)); } }
/** * 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['viewDataTable'] = 'ecommerceAbandonedCart'; $ecommerceCustomParams['filterEcommerce'] = self::ECOMMERCE_LOG_SHOW_ABANDONED_CARTS; } $goalReportsByDimension->addReport('Goals_EcommerceReports', 'Goals_ProductSKU', 'Goals.getItemsSku', $ecommerceCustomParams); $goalReportsByDimension->addReport('Goals_EcommerceReports', 'Goals_ProductName', 'Goals.getItemsName', $ecommerceCustomParams); $goalReportsByDimension->addReport('Goals_EcommerceReports', 'Goals_ProductCategory', 'Goals.getItemsCategory', $ecommerceCustomParams); $goalReportsByDimension->addReport('Goals_EcommerceReports', 'Goals_EcommerceLog', 'Goals.getEcommerceLog', $ecommerceCustomParams); } if ($conversions > 0) { // for non-Goals reports, we show the goals table $customParams = $ecommerceCustomParams + array('documentationForGoalsPage' => '1'); if (Common::getRequestVar('idGoal', '') === '') { $customParams['idGoal'] = '0'; // NOTE: Must be string! Otherwise Piwik_View_HtmlTable_Goals fails. } $allReports = Goals::getReportsWithGoalMetrics(); foreach ($allReports as $category => $reports) { $categoryText = Piwik::translate('Goals_ViewGoalsBy', $category); foreach ($reports as $report) { $customParams['viewDataTable'] = 'tableGoals'; if (in_array($report['action'], array('getVisitsUntilConversion', 'getDaysToConversion'))) { $customParams['viewDataTable'] = 'table'; } $goalReportsByDimension->addReport($categoryText, $report['name'], $report['module'] . '.' . $report['action'], $customParams); } } } return $goalReportsByDimension->render(); }
/** * 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', '') === '') { $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(); }