diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2011-04-20 12:28:42 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2011-04-20 12:28:42 +0400 |
commit | c35ecbc5c3d1eae97cc54b94bdd4235eebbe303b (patch) | |
tree | 5e2a4eb7baf10995b50f0e17c930cec0e135af29 /core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php | |
parent | 99ae24a5e44e0332880d2772347ffa3afb638a02 (diff) |
Fixes #2346
* Do not display Conversion rate from "All columns" view, when there is "per goal" metric available
* Do not display conversion rate on the "Goals" view
* Remove nb_visits_converted from the API when there is "per goal" metric
* Revenue per visit, is now based on the sum of revenue for all goals, rather than trusting the "revenue" field in the visit (in case Goal Revenue was attributed to a Referrer that is different from the visit Referrer where this conversion occurred)
API Breaking: nb_visits_converted not already in response anymore (only when there is no "per goal" metrics for this report)
git-svn-id: http://dev.piwik.org/svn/trunk@4525 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php')
-rw-r--r-- | core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php index f177d49a02..eb4359437e 100644 --- a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php +++ b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php @@ -61,6 +61,7 @@ class Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal extends Piwik_DataTa parent::filter($table); $roundingPrecision = 2; $expectedColumns = array(); + foreach($table->getRows() as $key => $row) { $currentColumns = $row->getColumns(); @@ -72,8 +73,16 @@ class Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal extends Piwik_DataTa $goals = $this->getColumn($currentColumns, Piwik_Archive::INDEX_GOALS); if($goals) { - $revenue = (int)$this->getColumn($currentColumns, Piwik_Archive::INDEX_REVENUE); - + $revenue = 0; + foreach($goals as $goalId => $columnValue) + { + $revenue += (int)$this->getColumn($columnValue, Piwik_Archive::INDEX_GOAL_REVENUE, Piwik_Archive::$mappingFromIdToNameGoal); + } + + if($revenue == 0) + { + $revenue = (int)$this->getColumn($currentColumns, Piwik_Archive::INDEX_REVENUE); + } // If no visit for this metric, but some conversions, we still want to display some kind of "revenue per visit" // even though it will actually be in this edge case "Revenue per conversion" $revenuePerVisit = $this->invalidDivision; |