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')
          || self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
        ) {
            return null;
        }


        switch ($attribute) {
            case 'title':
                // Matching on Page Title
                $actionToMatch = $action->getActionName();
                break;
            case 'event_action':
                $actionToMatch = $action->getEventAction();
                break;
            case 'event_name':
                $actionToMatch = $action->getEventName();
                break;
            case 'event_category':
                $actionToMatch = $action->getEventCategory();
                break;
            // url, external_website, file, manually...
            default:
                $actionToMatch = $action->getActionUrlRaw();
                break;
        }

        $pattern_type = $goal['pattern_type'];

        $match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
        if (!$match) {
            return null;
        }

        return $action->getActionUrl();
    }
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')
          || self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
        ) {
            return null;
        }


        switch ($attribute) {
            case 'title':
                // Matching on Page Title
                $actionToMatch = $action->getActionName();
                break;
            case 'event_action':
                $actionToMatch = $action->getEventAction();
                break;
            case 'event_name':
                $actionToMatch = $action->getEventName();
                break;
            case 'event_category':
                $actionToMatch = $action->getEventCategory();
                break;
            // url, external_website, file, manually...
            default:
                $actionToMatch = $action->getActionUrlRaw();
                break;
        }

        $pattern_type = $goal['pattern_type'];

        $match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
        if (!$match) {
            return null;
        }

        return $action->getActionUrl();
    }
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' ) || self :: isEventMatchingGoal ( $ goal ) && $ actionType != Action :: TYPE_EVENT ) { return null ; } switch ( $ attribute ) { case 'title' : // Matching on Page Title $ actionToMatch = $ action -> getActionName ( ) ; break ; case 'event_action' : $ actionToMatch = $ action -> getEventAction ( ) ; break ; case 'event_name' : $ actionToMatch = $ action -> getEventName ( ) ; break ; case 'event_category' : $ actionToMatch = $ action -> getEventCategory ( ) ; break ; // url, external_website, file, manually... default : $ actionToMatch = $ action -> getActionUrlRaw ( ) ; break ; } $ pattern_type = $ goal [ 'pattern_type' ] ; $ match = $ this -> isUrlMatchingGoal ( $ goal , $ pattern_type , $ actionToMatch ) ; if ( ! $ match ) { return null ; } return $ action -> getActionUrl ( ) ; }
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 if a goal is matched, a string of the Action URL is returned, or if no goal was matched it returns null
Detects if an Action matches a given goal . If it does the URL that triggered the goal is returned . Otherwise null is returned .