diff options
Diffstat (limited to 'core/Tracker/GoalManager.php')
-rw-r--r-- | core/Tracker/GoalManager.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index f1ff810891..29e6d508db 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -52,7 +52,7 @@ class Piwik_Tracker_GoalManager return $goal; } } - throw new Exception("The goal id = $idGoal couldn't be found."); + throw new Exception(Piwik_TranslateException('General_ExceptionGoalNotFound', array($idGoal))); } static public function getGoalIds( $idSite ) @@ -71,14 +71,14 @@ class Piwik_Tracker_GoalManager return Piwik_PluginsManager::getInstance()->isPluginActivated('Goals'); } - //TODO does this code work for manually triggered goals, with custom revenue? function detectGoalsMatchingUrl($idSite, $action) { if(!$this->isGoalPluginEnabled()) { return false; } - $url = $action->getActionUrl(); + $sanitizedUrl = $action->getActionUrl(); + $url = htmlspecialchars_decode($sanitizedUrl); $actionType = $action->getActionType(); $goals = $this->getGoalDefinitions($idSite); foreach($goals as $goal) @@ -129,12 +129,12 @@ class Piwik_Tracker_GoalManager $match = ($matched == 0); break; default: - throw new Exception("Pattern type $pattern_type not valid."); + throw new Exception(Piwik_TranslateException('General_ExceptionInvalidGoalPattern', array($pattern_type))); break; } if($match) { - $goal['url'] = $url; + $goal['url'] = $sanitizedUrl; $this->convertedGoals[] = $goal; } } @@ -154,7 +154,9 @@ class Piwik_Tracker_GoalManager return false; } $goal = $goals[$idGoal]; - $goal['url'] = Piwik_Common::getRequestVar( 'url', '', 'string', $request); + + $url = Piwik_Common::getRequestVar( 'url', '', 'string', $request); + $goal['url'] = Piwik_Tracker_Action::excludeQueryParametersFromUrl($url, $idSite); $goal['revenue'] = Piwik_Common::getRequestVar('revenue', $goal['revenue'], 'float', $request); $this->convertedGoals[] = $goal; return true; @@ -162,15 +164,22 @@ class Piwik_Tracker_GoalManager function recordGoals($visitorInformation, $action) { - $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Piwik_Common::getCountry(Piwik_Common::getBrowserLanguage(), $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess']); - $location_continent = isset($visitorInformation['location_continent']) ? $visitorInformation['location_continent'] : Piwik_Common::getContinent($location_country); + $location_country = isset($visitorInformation['location_country']) + ? $visitorInformation['location_country'] + : Piwik_Common::getCountry( + Piwik_Common::getBrowserLanguage(), + $enableLanguageToCountryGuess = Piwik_Tracker_Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip'] + ); + + $location_continent = isset($visitorInformation['location_continent']) + ? $visitorInformation['location_continent'] + : Piwik_Common::getContinent($location_country); $goal = array( 'idvisit' => $visitorInformation['idvisit'], 'idsite' => $visitorInformation['idsite'], 'visitor_idcookie' => $visitorInformation['visitor_idcookie'], 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), - 'visit_server_date' => $visitorInformation['visit_server_date'], 'location_country' => $location_country, 'location_continent'=> $location_continent, 'visitor_returning' => $this->cookie->get( Piwik_Tracker::COOKIE_INDEX_VISITOR_RETURNING ), @@ -207,14 +216,14 @@ class Piwik_Tracker_GoalManager try { Piwik_Tracker::getDatabase()->query( - "INSERT INTO " . Piwik_Common::prefixTable('log_conversion') . " ($fields) + "INSERT IGNORE INTO " . Piwik_Common::prefixTable('log_conversion') . " ($fields) VALUES ($bindFields) ", array_values($newGoal) ); } catch( Exception $e) { - if(Piwik_Tracker::isErrNo($e, '1062')) + if(Piwik_Tracker::getDatabase()->isErrNo($e, '1062')) { // integrity violation when same visit converts to the same goal twice - printDebug("--> Goal already recorded for this (idvisit, idgoal)"); + printDebug("--> Goal already recorded for this (idvisit, idgoal)"); } else { |