Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing incorrect goal conversion rate metric in tableGoals view

  • Loading branch information...
commit 4a6018b92d9b516922d27de46ef6bc64052e5fb2 1 parent bf2cd5c
matt authored
View
4 core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php
@@ -58,6 +58,9 @@ public function __construct( $table, $enable = true, $processOnlyIdGoal )
protected function filter()
{
+ // Add standard processed metrics
+ parent::filter();
+
$roundingPrecision = 2;
$expectedColumns = array();
foreach($this->table->getRows() as $key => $row)
@@ -145,7 +148,6 @@ protected function filter()
$row->addColumns($newColumns);
}
$expectedColumns['revenue_per_visit'] = true;
- $expectedColumns['conversion_rate'] = true;
// make sure all goals values are set, 0 by default
// if no value then sorting would put at the end
View
19 plugins/API/API.php
@@ -310,8 +310,6 @@ private function handleTableReport($idSite, $period, $dataTable, $reportMetadata
if(isset($reportMetadata['processedMetrics']))
{
- // Add processed metrics
- $dataTable->filter('AddColumnsProcessedMetrics');
$processedMetricsAdded = Piwik_API_API::getInstance()->getDefaultProcessedMetrics();
foreach($processedMetricsAdded as $processedMetricId => $processedMetricTranslation)
{
@@ -327,10 +325,6 @@ private function handleTableReport($idSite, $period, $dataTable, $reportMetadata
{
$metricsGoalDisplay = array('conversion_rate', 'revenue');
- // to have conversion_rate, we need to apply the Goal processed filter
- // only requesting to process the basic metrics
- $dataTable->filter('AddColumnsProcessedMetricsGoal', array($enable=true, Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_MINIMAL_REPORT));
-
// Add processed metrics to be displayed for this report
foreach($metricsGoalDisplay as $goalMetricId)
{
@@ -340,6 +334,19 @@ private function handleTableReport($idSite, $period, $dataTable, $reportMetadata
}
}
}
+ if(isset($reportMetadata['metricsGoal']))
+ {
+ // To process conversion_rate, we need to apply the Goal processed filter
+ // only requesting to process the basic metrics
+ // This adds goal metrics as well as standard metrics
+ $dataTable->filter('AddColumnsProcessedMetricsGoal', array($enable=true, Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_MINIMAL_REPORT));
+ }
+ elseif(isset($reportMetadata['processedMetrics']))
+ {
+ // Add processed metrics
+ $dataTable->filter('AddColumnsProcessedMetrics');
+ }
+
$dataTable->filter('SafeDecodeLabel', array($outputHTML = false));
$renderer = new Piwik_DataTable_Renderer_Php();
$renderer->setTable($dataTable);
Please sign in to comment.
Something went wrong with that request. Please try again.