protected function AcquiaLiftReportBase::extractConversionReportData in Acquia Lift Connector 7
Extracts data from the raw confidence detail report that is prepared for use within the conversion report rendering process.
Parameters
$items: An array of items as return from Acquia Lift.
Return value
array An associative array with information about the performance of each choice.
1 call to AcquiaLiftReportBase::extractConversionReportData()
- AcquiaLiftReportBase::loadConversionReportHelper in plugins/
agent_types/ AcquiaLiftAgent.inc - Handles all of the logic to load and extract a conversion report.
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 1687 - Provides an agent type for Acquia Lift
Class
- AcquiaLiftReportBase
- Base class providing report data loading functionality common to all Acquia Lift Reports.
Code
protected function extractConversionReportData($items) {
if (empty($items)) {
return array();
}
$shown = array();
$counter = NAN;
$data = array();
$total_count = $total_goals = $total_val = array();
foreach ($items as $item) {
// Check to see if we are in a new grouping of choices.
$check = $item['choice'];
if (is_nan($counter) || isset($shown[$check])) {
$shown = array();
$counter = 0;
}
else {
$counter++;
}
$shown[$check] = $check;
$choice = $option_id = $item['choice'];
$choice_id = $choice;
if (strpos($choice, ':') !== FALSE) {
list($decision_name, $option_id) = explode(':', $choice);
}
if ($option_label = personalize_get_option_label_for_decision_and_choice($decision_name, $option_id)) {
$choice_id = $option_label;
}
$goals = $item['totals']['goals'];
$count = $item['totals']['count'];
$val = $item['totals']['val'];
$total_count[$counter] = isset($total_count[$counter]) ? $total_count[$counter] + $count : $count;
$total_goals[$counter] = isset($total_goals[$counter]) ? $total_goals[$counter] + $goals : $goals;
$total_val[$counter] = isset($total_val[$counter]) ? $total_val[$counter] + $val : $val;
$rate = $total_count[$counter] > 0 ? $total_goals[$counter] / $total_count[$counter] * 100 : 0;
$val_rate = $total_count[$counter] > 0 ? $total_val[$counter] / $total_count[$counter] : 0;
$margin = ($item['bHi'] - $item['bLo']) / 2;
$data[$item['feature']][] = array(
'choice_id' => $choice_id,
'raw_label' => $option_id,
'goals' => $total_goals[$counter],
'count' => $total_count[$counter],
'date' => $item['date'],
'timestamp' => strtotime($item['date']),
'conversion' => $this
->formatReportNumber($rate, TRUE, 4),
'conversion_value' => $this
->formatReportNumber($val_rate, TRUE, 4),
'estimated_value' => $this
->formatReportNumber($item['vMean'], TRUE, 4),
'margin_error' => $this
->formatReportNumber($margin, TRUE, 4),
'counter' => $counter,
'control' => $counter === 0,
);
}
return $data;
}