コード例 #1
0
 /**
  * @dataProvider getSearchEngineUrls
  * @group Core
  */
 public function testExtractSearchEngineInformationFromUrl($url, $engine, $keywords)
 {
     $this->includeDataFilesForSearchEngineTest();
     $returnedValue = UrlHelper::extractSearchEngineInformationFromUrl($url);
     $exptectedValue = false;
     if (!empty($engine)) {
         $exptectedValue = array('name' => $engine, 'keywords' => $keywords);
     }
     $this->assertEquals($exptectedValue, $returnedValue);
 }
コード例 #2
0
ファイル: Base.php プロジェクト: nuxwin/piwik
 protected function detectCampaignKeywordFromReferrerUrl()
 {
     if (!empty($this->nameReferrerAnalyzed) && !empty($this->keywordReferrerAnalyzed)) {
         // keyword is already set, we skip
         return true;
     }
     // Set the Campaign keyword to the keyword found in the Referrer URL if any
     if (!empty($this->nameReferrerAnalyzed)) {
         $referrerUrlInfo = UrlHelper::extractSearchEngineInformationFromUrl($this->referrerUrl);
         if (!empty($referrerUrlInfo['keywords'])) {
             $this->keywordReferrerAnalyzed = $referrerUrlInfo['keywords'];
         }
     }
     // Set the keyword, to the hostname found, in a Adsense Referrer URL '&url=' parameter
     if (empty($this->keywordReferrerAnalyzed) && !empty($this->referrerUrlParse['query']) && !empty($this->referrerHost) && (strpos($this->referrerHost, 'googleads') !== false || strpos($this->referrerHost, 'doubleclick') !== false)) {
         // This parameter sometimes is found & contains the page with the adsense ad bringing visitor to our site
         $value = $this->getParameterValueFromReferrerUrl('url');
         if (!empty($value)) {
             $parsedAdsenseReferrerUrl = parse_url($value);
             if (!empty($parsedAdsenseReferrerUrl['host'])) {
                 if (empty($this->nameReferrerAnalyzed)) {
                     $type = $this->getParameterValueFromReferrerUrl('ad_type');
                     $type = $type ? " ({$type})" : '';
                     $this->nameReferrerAnalyzed = self::LABEL_ADWORDS_NAME . $type;
                     $this->typeReferrerAnalyzed = Common::REFERRER_TYPE_CAMPAIGN;
                 }
                 $this->keywordReferrerAnalyzed = self::LABEL_PREFIX_ADWORDS_KEYWORD . $parsedAdsenseReferrerUrl['host'];
             }
         }
     }
 }