Beispiel #1
0
 public function products()
 {
     $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
     $conversions = 0;
     if (!empty($goal['nb_conversions'])) {
         $conversions = $goal['nb_conversions'];
     }
     $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
     $cartNbConversions = 0;
     if (!empty($goal) && array_key_exists('nb_conversions', $goal)) {
         $cartNbConversions = $goal['nb_conversions'];
     }
     $preloadAbandonedCart = $cartNbConversions !== false && $conversions == 0;
     $goalReportsByDimension = new View\ReportsByDimension('Goals');
     $ecommerceCustomParams = array();
     if ($preloadAbandonedCart) {
         $ecommerceCustomParams['abandonedCarts'] = '1';
     } else {
         $ecommerceCustomParams['abandonedCarts'] = '0';
     }
     $goalReportsByDimension->addReport('Goals_Products', 'Goals_ProductSKU', 'Goals.getItemsSku', $ecommerceCustomParams);
     $goalReportsByDimension->addReport('Goals_Products', 'Goals_ProductName', 'Goals.getItemsName', $ecommerceCustomParams);
     $goalReportsByDimension->addReport('Goals_Products', 'Goals_ProductCategory', 'Goals.getItemsCategory', $ecommerceCustomParams);
     $view = new View('@Ecommerce/products');
     $this->setGeneralVariablesView($view);
     $view->productsByDimension = $goalReportsByDimension->render();
     return $view->render();
 }
Beispiel #2
0
 public function index()
 {
     $reportsView = new View\ReportsByDimension('Contents');
     /** @var \Piwik\Plugin\Report[] $reports */
     $reports = array(new GetContentNames(), new GetContentPieces());
     foreach ($reports as $report) {
         $reportsView->addReport($report->getCategory(), $report->getName(), 'Contents.menu' . ucfirst($report->getAction()));
     }
     return $reportsView->render();
 }
Beispiel #3
0
 private function getLeftMenuReports()
 {
     $reports = new View\ReportsByDimension('Events');
     foreach (Events::getLabelTranslations() as $apiAction => $translations) {
         // 'getCategory' is the API method, but we are loading 'indexCategory' which displays <h2>
         $count = 1;
         $controllerAction = str_replace("get", "index", $apiAction, $count);
         $params = array('secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($apiAction));
         $reports->addReport('Events_TopEvents', $translations[0], 'Events.' . $controllerAction, $params);
     }
     return $reports->render();
 }
Beispiel #4
0
 public function index()
 {
     $reportsView = new View\ReportsByDimension('Contents');
     /** @var \Piwik\Plugin\Report[] $reports */
     $contentNames = Report::factory($this->pluginName, 'getContentNames');
     $contentPieces = Report::factory($this->pluginName, 'getContentPieces');
     $reports = array($contentNames, $contentPieces);
     foreach ($reports as $report) {
         $reportsView->addReport($report->getCategory(), $report->getName(), 'Contents.' . Report::PREFIX_ACTION_IN_MENU . ucfirst($report->getAction()));
     }
     return $reportsView->render();
 }
Beispiel #5
0
 /**
  * Returns HTML for the Referrers Overview page that categorizes Referrer reports
  * & allows the user to switch between them.
  *
  * @param int $visits The number of visits for this period & site. If <= 0, the
  *                    reports are not shown, since they will have no data.getReferrersReportsByDimensionView
  * @return string The report viewer HTML.
  */
 private function getReferrersReportsByDimensionView($visits)
 {
     $result = '';
     // only display the reports by dimension view if there are visits
     if ($visits > 0) {
         $referrersReportsByDimension = new View\ReportsByDimension('Referrers');
         $referrersReportsByDimension->addReport('Referrers_ViewAllReferrers', 'Referrers_WidgetGetAll', 'Referrers.getAll');
         $byTypeCategory = Piwik::translate('Referrers_ViewReferrersBy', Piwik::translate('Live_GoalType'));
         $referrersReportsByDimension->addReport($byTypeCategory, 'Referrers_WidgetKeywords', 'Referrers.getKeywords');
         $referrersReportsByDimension->addReport($byTypeCategory, 'SitesManager_Sites', 'Referrers.getWebsites');
         $referrersReportsByDimension->addReport($byTypeCategory, 'Referrers_Campaigns', 'Referrers.getCampaigns');
         $bySourceCategory = Piwik::translate('Referrers_ViewReferrersBy', Piwik::translate('General_Source'));
         $referrersReportsByDimension->addReport($bySourceCategory, 'Referrers_Socials', 'Referrers.getSocials');
         $referrersReportsByDimension->addReport($bySourceCategory, 'Referrers_SearchEngines', 'Referrers.getSearchEngines');
         $result = $referrersReportsByDimension->render();
     }
     return $result;
 }
 /**
  * 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();
 }