protected function enrichWithConversions(&$data)
    {
        foreach ($data as &$values) {
            if (!isset($values[Metrics::INDEX_GOALS])) {
                continue;
            }
            // When per goal metrics are processed, general 'visits converted' is not meaningful because
            // it could differ from the sum of each goal conversions
            unset($values[Metrics::INDEX_NB_VISITS_CONVERTED]);
            $revenue = $conversions = 0;
            foreach ($values[Metrics::INDEX_GOALS] as $idgoal => $goalValues) {
                // Do not sum Cart revenue since it is a lost revenue
                if ($idgoal >= GoalManager::IDGOAL_ORDER) {
                    $revenue += $goalValues[Metrics::INDEX_GOAL_REVENUE];
                    $conversions += $goalValues[Metrics::INDEX_GOAL_NB_CONVERSIONS];
                }
            }
            $values[Metrics::INDEX_NB_CONVERSIONS] = $conversions;

            // 25.00 recorded as 25
            if (round($revenue) == $revenue) {
                $revenue = round($revenue);
            }
            $values[Metrics::INDEX_REVENUE] = $revenue;

            // if there are no "visit" column, we force one to prevent future complications
            // eg. This helps the setDefaultColumnsToDisplay() call
            if (!isset($values[Metrics::INDEX_NB_VISITS])) {
                $values[Metrics::INDEX_NB_VISITS] = 0;
            }
        }
    }
protected function enrichWithConversions(&$data)
    {
        foreach ($data as &$values) {
            if (!isset($values[Metrics::INDEX_GOALS])) {
                continue;
            }
            // When per goal metrics are processed, general 'visits converted' is not meaningful because
            // it could differ from the sum of each goal conversions
            unset($values[Metrics::INDEX_NB_VISITS_CONVERTED]);
            $revenue = $conversions = 0;
            foreach ($values[Metrics::INDEX_GOALS] as $idgoal => $goalValues) {
                // Do not sum Cart revenue since it is a lost revenue
                if ($idgoal >= GoalManager::IDGOAL_ORDER) {
                    $revenue += $goalValues[Metrics::INDEX_GOAL_REVENUE];
                    $conversions += $goalValues[Metrics::INDEX_GOAL_NB_CONVERSIONS];
                }
            }
            $values[Metrics::INDEX_NB_CONVERSIONS] = $conversions;

            // 25.00 recorded as 25
            if (round($revenue) == $revenue) {
                $revenue = round($revenue);
            }
            $values[Metrics::INDEX_REVENUE] = $revenue;

            // if there are no "visit" column, we force one to prevent future complications
            // eg. This helps the setDefaultColumnsToDisplay() call
            if (!isset($values[Metrics::INDEX_NB_VISITS])) {
                $values[Metrics::INDEX_NB_VISITS] = 0;
            }
        }
    }
protected function enrichWithConversions ( & $ data ) { foreach ( $ data as & $ values ) { if ( ! isset ( $ values [ Metrics :: INDEX_GOALS ] ) ) { continue ; } // When per goal metrics are processed, general 'visits converted' is not meaningful because // it could differ from the sum of each goal conversions unset ( $ values [ Metrics :: INDEX_NB_VISITS_CONVERTED ] ) ; $ revenue = $ conversions = 0 ; foreach ( $ values [ Metrics :: INDEX_GOALS ] as $ idgoal => $ goalValues ) { // Do not sum Cart revenue since it is a lost revenue if ( $ idgoal >= GoalManager :: IDGOAL_ORDER ) { $ revenue += $ goalValues [ Metrics :: INDEX_GOAL_REVENUE ] ; $ conversions += $ goalValues [ Metrics :: INDEX_GOAL_NB_CONVERSIONS ] ; } } $ values [ Metrics :: INDEX_NB_CONVERSIONS ] = $ conversions ; // 25.00 recorded as 25 if ( round ( $ revenue ) == $ revenue ) { $ revenue = round ( $ revenue ) ; } $ values [ Metrics :: INDEX_REVENUE ] = $ revenue ; // if there are no "visit" column, we force one to prevent future complications // eg. This helps the setDefaultColumnsToDisplay() call if ( ! isset ( $ values [ Metrics :: INDEX_NB_VISITS ] ) ) { $ values [ Metrics :: INDEX_NB_VISITS ] = 0 ; } } }
Given an array of stats, it will process the sum of goal conversions
and sum of revenue and add it in the stats array in two new fields.

@param array $data Passed by reference, two new columns
will be added: total conversions, and total revenue, for all goals for this label/row
Given an array of stats it will process the sum of goal conversions and sum of revenue and add it in the stats array in two new fields .