For example, "getKeywords" returns all search engine keywords (with general analytics metrics for each keyword), "getWebsites" returns referrer websites (along with the full Referrer URL if the parameter &expanded=1 is set). "getReferrerType" returns the Referrer overview report. "getCampaigns" returns the list of all campaigns (and all campaign keywords if the parameter &expanded=1 is set). The methods "getKeywordsForPageUrl" and "getKeywordsForPageTitle" are used to output the top keywords used to find a page. Check out the widget "Top keywords used to find this page" that you can easily re-use on your website.
Inheritance: extends Piwik\Plugin\API
Exemplo n.º 1
0
 public function getKeyword()
 {
     $keyword = $this->details['referer_keyword'];
     if ($this->getReferrerType() == 'search') {
         $keyword = API::getCleanKeyword($keyword);
     }
     return urldecode($keyword);
 }
 public function filter($table)
 {
     foreach ($table->getRows() as $row) {
         $typeReferrer = $row->getColumn('label');
         if ($typeReferrer != Common::REFERRER_TYPE_DIRECT_ENTRY) {
             if (!$this->expanded) {
                 $row->setNonLoadedSubtableId($typeReferrer);
             } else {
                 if (!Range::isMultiplePeriod($this->date, $this->period)) {
                     // otherwise, we have to get the other datatables
                     // NOTE: not yet possible to do this w/ DataTable\Map instances
                     // (actually it would be maybe possible by using $map->mergeChildren() or so build it would be slow)
                     $subtable = API::getInstance()->getReferrerType($this->idSite, $this->period, $this->date, $this->segment, $type = false, $idSubtable = $typeReferrer);
                     if ($this->expanded) {
                         $subtable->applyQueuedFilters();
                     }
                     $row->setSubtable($subtable);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 protected function getTopDimensions($idGoal)
 {
     $columnNbConversions = 'goal_' . $idGoal . '_nb_conversions';
     $columnConversionRate = 'goal_' . $idGoal . '_conversion_rate';
     $topDimensionsToLoad = array();
     if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('UserCountry')) {
         $topDimensionsToLoad += array('country' => 'UserCountry.getCountry');
     }
     $keywordNotDefinedString = '';
     if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('Referrers')) {
         $keywordNotDefinedString = APIReferrers::getKeywordNotDefinedString();
         $topDimensionsToLoad += array('keyword' => 'Referrers.getKeywords', 'website' => 'Referrers.getWebsites');
     }
     $topDimensions = array();
     foreach ($topDimensionsToLoad as $dimensionName => $apiMethod) {
         $request = new Request("method={$apiMethod}\n\t\t\t\t\t\t\t\t&format=original\n\t\t\t\t\t\t\t\t&filter_update_columns_when_show_all_goals=1\n\t\t\t\t\t\t\t\t&idGoal=" . AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE . "\n\t\t\t\t\t\t\t\t&filter_sort_order=desc\n\t\t\t\t\t\t\t\t&filter_sort_column={$columnNbConversions}" . "&filter_limit=" . (self::COUNT_TOP_ROWS_TO_DISPLAY + 2));
         $datatable = $request->process();
         $topDimension = array();
         $count = 0;
         foreach ($datatable->getRows() as $row) {
             $conversions = $row->getColumn($columnNbConversions);
             if ($conversions > 0 && $count < self::COUNT_TOP_ROWS_TO_DISPLAY && !($dimensionName == 'keyword' && $row->getColumn('label') == $keywordNotDefinedString)) {
                 $topDimension[] = array('name' => $row->getColumn('label'), 'nb_conversions' => $conversions, 'conversion_rate' => $this->formatConversionRate($row->getColumn($columnConversionRate)), 'metadata' => $row->getMetadata());
                 $count++;
             }
         }
         $topDimensions[$dimensionName] = $topDimension;
     }
     return $topDimensions;
 }
Exemplo n.º 4
0
 function getKeyword()
 {
     $keyword = $this->details['referer_keyword'];
     if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('Referrers') && $this->getReferrerType() == 'search') {
         $keyword = \Piwik\Plugins\Referrers\API::getCleanKeyword($keyword);
     }
     return urldecode($keyword);
 }
Exemplo n.º 5
0
 /**
  * Returns a summary for a visit's referral.
  *
  * @param Row $visit
  * @return bool|mixed|string
  * @ignore
  */
 public static function getReferrerSummaryForVisit($visit)
 {
     $referrerType = $visit->getColumn('referrerType');
     if ($referrerType === false || $referrerType == 'direct') {
         $result = Piwik::translate('Referrers_DirectEntry');
     } else {
         if ($referrerType == 'search') {
             $result = $visit->getColumn('referrerName');
             $keyword = $visit->getColumn('referrerKeyword');
             if ($keyword !== false && $keyword != APIReferrers::getKeywordNotDefinedString()) {
                 $result .= ' (' . $keyword . ')';
             }
         } else {
             if ($referrerType == 'campaign') {
                 $result = Piwik::translate('Referrers_ColumnCampaign') . ' (' . $visit->getColumn('referrerName') . ')';
             } else {
                 $result = $visit->getColumn('referrerName');
             }
         }
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Returns a summary for a visit's referral.
  *
  * @param DataTable\Row $visit
  * @return bool|mixed|string
  */
 public static function getReferrerSummaryForVisit($visit)
 {
     $referrerType = $visit->getColumn('referrerType');
     if ($referrerType === false || $referrerType == 'direct') {
         return Piwik::translate('Referrers_DirectEntry');
     }
     if ($referrerType == 'search') {
         $referrerName = $visit->getColumn('referrerName');
         $keyword = $visit->getColumn('referrerKeyword');
         if ($keyword !== false && $keyword != APIReferrers::getKeywordNotDefinedString()) {
             $referrerName .= ' (' . $keyword . ')';
         }
         return $referrerName;
     }
     if ($referrerType == 'campaign') {
         $summary = Piwik::translate('Referrers_ColumnCampaign') . ': ' . $visit->getColumn('referrerName');
         $keyword = $visit->getColumn('referrerKeyword');
         if (!empty($keyword)) {
             $summary .= ' - ' . $keyword;
         }
         return $summary;
     }
     return $visit->getColumn('referrerName');
 }