getActionUrl() public method

Returns URL of the page currently being tracked, or the file being downloaded, or the outlink being clicked
public getActionUrl ( ) : string
return string
示例#1
0
 /**
  * Detect whether action is an outlink given host aliases
  *
  * @param Action $action
  * @return bool true if the outlink the visitor clicked on points to one of the known hosts for this website
  */
 protected function detectActionIsOutlinkOnAliasHost(Action $action, $idSite)
 {
     $decodedActionUrl = $action->getActionUrl();
     $actionUrlParsed = @parse_url($decodedActionUrl);
     if (!isset($actionUrlParsed['host'])) {
         return false;
     }
     return Visit::isHostKnownAliasHost($actionUrlParsed['host'], $idSite);
 }
示例#2
0
 /**
  * Detect whether action is an outlink given host aliases
  *
  * @param Action $action
  * @return bool true if the outlink the visitor clicked on points to one of the known hosts for this website
  */
 public static function detectActionIsOutlinkOnAliasHost(Action $action, $idSite)
 {
     if ($action->getActionType() != Action::TYPE_OUTLINK) {
         return false;
     }
     $decodedActionUrl = $action->getActionUrl();
     $actionUrlParsed = @parse_url($decodedActionUrl);
     if (!isset($actionUrlParsed['host'])) {
         return false;
     }
     return Visit::isHostKnownAliasHost($actionUrlParsed['host'], $idSite);
 }
示例#3
0
 /**
  * Look at the URL or Page Title and sees if it matches any existing Goal definition
  *
  * @param int $idSite
  * @param Action $action
  * @throws Exception
  * @return int Number of goals matched
  */
 public function detectGoalsMatchingUrl($idSite, $action)
 {
     if (!Common::isGoalPluginEnabled()) {
         return false;
     }
     $actionType = $action->getActionType();
     $goals = $this->getGoalDefinitions($idSite);
     foreach ($goals as $goal) {
         $attribute = $goal['match_attribute'];
         // if the attribute to match is not the type of the current action
         if (($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL || $attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD || $attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK || $attribute == 'manually' || in_array($attribute, array('event_action', 'event_name', 'event_category')) && $actionType != Action::TYPE_EVENT) {
             continue;
         }
         switch ($attribute) {
             case 'title':
                 // Matching on Page Title
                 $url = $action->getActionName();
                 break;
             case 'event_action':
                 $url = $action->getEventAction();
                 break;
             case 'event_name':
                 $url = $action->getEventName();
                 break;
             case 'event_category':
                 $url = $action->getEventCategory();
                 break;
                 // url, external_website, file, manually...
             // url, external_website, file, manually...
             default:
                 $url = $action->getActionUrlRaw();
                 break;
         }
         $pattern_type = $goal['pattern_type'];
         $match = $this->isUrlMatchingGoal($goal, $pattern_type, $url);
         if ($match) {
             $goal['url'] = $action->getActionUrl();
             $this->convertedGoals[] = $goal;
         }
     }
     return count($this->convertedGoals) > 0;
 }
示例#4
0
 /**
  * Look at the URL or Page Title and sees if it matches any existing Goal definition
  *
  * @param int $idSite
  * @param Action $action
  * @throws Exception
  * @return int Number of goals matched
  */
 function detectGoalsMatchingUrl($idSite, $action)
 {
     if (!Common::isGoalPluginEnabled()) {
         return false;
     }
     $decodedActionUrl = $action->getActionUrl();
     $actionType = $action->getActionType();
     $goals = $this->getGoalDefinitions($idSite);
     foreach ($goals as $goal) {
         $attribute = $goal['match_attribute'];
         // if the attribute to match is not the type of the current action
         if (($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL || $attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD || $attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK || $attribute == 'manually') {
             continue;
         }
         $url = $decodedActionUrl;
         // Matching on Page Title
         if ($attribute == 'title') {
             $url = $action->getActionName();
         }
         $pattern_type = $goal['pattern_type'];
         $match = $this->isUrlMatchingGoal($goal, $pattern_type, $url);
         if ($match) {
             $goal['url'] = $decodedActionUrl;
             $this->convertedGoals[] = $goal;
         }
     }
     return count($this->convertedGoals) > 0;
 }
示例#5
0
 /**
  * Detects if an Action matches a given goal. If it does, the URL that triggered the goal
  * is returned. Otherwise null is returned.
  *
  * @param array $goal
  * @param Action $action
  * @return string|null
  */
 public function detectGoalMatch($goal, Action $action)
 {
     $actionType = $action->getActionType();
     $attribute = $goal['match_attribute'];
     // if the attribute to match is not the type of the current action
     if (($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL || $attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD || $attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK || $attribute == 'manually' || in_array($attribute, array('event_action', 'event_name', 'event_category')) && $actionType != Action::TYPE_EVENT) {
         return null;
     }
     switch ($attribute) {
         case 'title':
             // Matching on Page Title
             $url = $action->getActionName();
             break;
         case 'event_action':
             $url = $action->getEventAction();
             break;
         case 'event_name':
             $url = $action->getEventName();
             break;
         case 'event_category':
             $url = $action->getEventCategory();
             break;
             // url, external_website, file, manually...
         // url, external_website, file, manually...
         default:
             $url = $action->getActionUrlRaw();
             break;
     }
     $pattern_type = $goal['pattern_type'];
     $match = $this->isUrlMatchingGoal($goal, $pattern_type, $url);
     if (!$match) {
         return null;
     }
     return $action->getActionUrl();
 }
 /**
  * Look at the URL or Page Title and sees if it matches any existing Goal definition
  *
  * @param int $idSite
  * @param Action $action
  * @throws Exception
  * @return int Number of goals matched
  */
 function detectGoalsMatchingUrl($idSite, $action)
 {
     if (!Common::isGoalPluginEnabled()) {
         return false;
     }
     $decodedActionUrl = $action->getActionUrl();
     $actionType = $action->getActionType();
     $goals = $this->getGoalDefinitions($idSite);
     foreach ($goals as $goal) {
         $attribute = $goal['match_attribute'];
         // if the attribute to match is not the type of the current action
         if ($actionType == Action::TYPE_PAGE_URL && $attribute != 'url' && $attribute != 'title' || $actionType == Action::TYPE_DOWNLOAD && $attribute != 'file' || $actionType == Action::TYPE_OUTLINK && $attribute != 'external_website' || $attribute == 'manually') {
             continue;
         }
         $url = $decodedActionUrl;
         // Matching on Page Title
         if ($attribute == 'title') {
             $url = $action->getActionName();
         }
         $pattern_type = $goal['pattern_type'];
         switch ($pattern_type) {
             case 'regex':
                 $pattern = $goal['pattern'];
                 if (strpos($pattern, '/') !== false && strpos($pattern, '\\/') === false) {
                     $pattern = str_replace('/', '\\/', $pattern);
                 }
                 $pattern = '/' . $pattern . '/';
                 if (!$goal['case_sensitive']) {
                     $pattern .= 'i';
                 }
                 $match = @preg_match($pattern, $url) == 1;
                 break;
             case 'contains':
                 if ($goal['case_sensitive']) {
                     $matched = strpos($url, $goal['pattern']);
                 } else {
                     $matched = stripos($url, $goal['pattern']);
                 }
                 $match = $matched !== false;
                 break;
             case 'exact':
                 if ($goal['case_sensitive']) {
                     $matched = strcmp($goal['pattern'], $url);
                 } else {
                     $matched = strcasecmp($goal['pattern'], $url);
                 }
                 $match = $matched == 0;
                 break;
             default:
                 throw new Exception(Piwik::translate('General_ExceptionInvalidGoalPattern', array($pattern_type)));
                 break;
         }
         if ($match) {
             $goal['url'] = $decodedActionUrl;
             $this->convertedGoals[] = $goal;
         }
     }
     return count($this->convertedGoals) > 0;
 }