Esempio n. 1
0
 /**
  * Add the external referrers to the report:
  * direct entries, websites, campaigns, search engines
  *
  * @param LogAggregator $logAggregator
  * @param $report
  * @param $idaction
  * @param string $actionType
  * @param $limitBeforeGrouping
  */
 private function addExternalReferrers($logAggregator, &$report, $idaction, $actionType, $limitBeforeGrouping)
 {
     $data = $this->queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping);
     $report['pageMetrics']['entries'] = 0;
     $report['referrers'] = array();
     foreach ($data->getRows() as $row) {
         $referrerId = $row->getColumn('label');
         $visits = $row->getColumn(Metrics::INDEX_NB_VISITS);
         if ($visits) {
             // load details (i.e. subtables)
             $details = array();
             if ($idSubTable = $row->getIdSubDataTable()) {
                 $subTable = Manager::getInstance()->getTable($idSubTable);
                 foreach ($subTable->getRows() as $subRow) {
                     $details[] = array('label' => $subRow->getColumn('label'), 'referrals' => $subRow->getColumn(Metrics::INDEX_NB_VISITS));
                 }
             }
             $report['referrers'][] = array('label' => $this->getReferrerLabel($referrerId), 'shortName' => \Piwik\Plugins\Referrers\getReferrerTypeFromShortName($referrerId), 'visits' => $visits, 'details' => $details);
             $report['pageMetrics']['entries'] += $visits;
         }
     }
     // if there's no data for referrers, ResponseBuilder::handleMultiDimensionalArray
     // does not detect the multi dimensional array and the data is rendered differently, which
     // causes an exception.
     if (count($report['referrers']) == 0) {
         $report['referrers'][] = array('label' => $this->getReferrerLabel(Common::REFERRER_TYPE_DIRECT_ENTRY), 'shortName' => \Piwik\Plugins\Referrers\getReferrerTypeLabel(Common::REFERRER_TYPE_DIRECT_ENTRY), 'visits' => 0);
     }
 }
Esempio n. 2
0
 function getReferrerTypeName()
 {
     return \Piwik\Plugins\Referrers\getReferrerTypeLabel($this->details['referer_type']);
 }