diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php
index 6fc3233126b96d350c94aa63ed405c045a6f5784..939565e7fe2180813cc485c56dbe05fba8a0f28e 100644
--- a/core/Tracker/GoalManager.php
+++ b/core/Tracker/GoalManager.php
@@ -141,9 +141,9 @@ class GoalManager
         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')
+            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;
@@ -156,40 +156,7 @@ class GoalManager
             }
             $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;
-            }
+            $match = $this->isUrlMatchingGoal($goal, $pattern_type, $url);
             if ($match) {
                 $goal['url'] = $decodedActionUrl;
                 $this->convertedGoals[] = $goal;
@@ -887,4 +854,50 @@ class GoalManager
             }
         }
     }
+
+    /**
+     * @param $goal
+     * @param $pattern_type
+     * @param $url
+     * @return bool
+     * @throws \Exception
+     */
+    protected function isUrlMatchingGoal($goal, $pattern_type, $url)
+    {
+        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;
+        }
+        return $match;
+    }
 }