protected function AcquiaLiftReportBase::buildConversionSummaryReport in Acquia Lift Connector 7
Builds the render array for the summary portion of the report.
Parameters
array $report_data: Reporting data for this summary report.
array $all_report_data: The report data for all reports to be build including overview data.
array|bool: A render array for the report or FALSE if it cannot be generated.
1 call to AcquiaLiftReportBase::buildConversionSummaryReport()
- AcquiaLiftReportBase::buildConversionReports in plugins/
agent_types/ AcquiaLiftAgent.inc - Build a set of confidence reports from the report data.
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 1949 - 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 buildConversionSummaryReport($report_data, $all_report_data) {
if ($report_data === FALSE) {
return FALSE;
}
$confidence = !empty($all_report_data['conversion_all']['summary']['overview']['confidence']);
$winner = $all_report_data['conversion_all']['summary']['overview']['winner'];
$headers = array(
t('Variation'),
array(
'data' => t('Total goals met'),
'data-help-tooltip' => t('Number of times visitors completed a goal after viewing the variation.'),
),
array(
'data' => t('Total conversion rate'),
'data-help-tooltip' => t('Percentage of goals met for each display of the variation.'),
),
array(
'data' => t('Chance to beat control'),
'data-help-tooltip' => t('Likelihood visitors will complete goals for a variation compared to the control.'),
),
array(
'data' => t('Lift'),
'data-help-tooltip' => t('Likelihood visitors will complete goals for a variation compared to the control.'),
),
array(
'data' => t('Winner'),
'data-help-tooltip' => t('Most effective variation for visitors based on a @confidence% confidence level.', array(
'@confidence' => $this
->getConfidenceMeasure(),
)),
),
);
$confidence_message_shown = FALSE;
$rows = array();
foreach ($report_data['data'] as $feature => $feature_data) {
if (!in_array($feature, $all_report_data['features'])) {
continue;
}
foreach ($feature_data as $data) {
$row_data = array(
array(
'data' => $data['choice_id'],
'data-acquia-lift-variation-label' => $this
->getVariationLabel($data['counter'], $data['control']),
),
array(
'data' => $data['goals'],
),
array(
'data' => $data['conversion'],
),
array(
'data' => $data['confidence'],
),
array(
'data' => $data['lift_default'],
),
);
// Add the winner column data.
if (empty($rows) && !$confidence) {
// If there is low confidence then show the message throughout the
// winner column.
$row_data[] = array(
'data' => $this
->getLowConfidenceMessage(),
'rowspan' => count($feature_data),
'class' => array(
'acquia-lift-ab-winner',
),
);
$confidence_message_shown = TRUE;
}
else {
if (!$confidence_message_shown) {
// Show the winner indicator if this is the winning variation.
$row_data[] = $confidence && $winner === $data['counter'] ? '<span class="lift-winner">' . t('Winner') . '</span>' : '';
}
}
$rows[] = array(
'data' => $row_data,
'no_striping' => TRUE,
);
}
}
if (empty($rows)) {
return array();
}
$build['summary_holder'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'lift-graph-result',
),
),
);
$build['summary_holder']['summary_table'] = array(
'#theme' => 'table',
'#header' => $headers,
'#rows' => $rows,
'#sticky' => FALSE,
'#attributes' => array(
'class' => array(
'lift-graph-result-data',
),
'data-acquia-lift-campaign' => $all_report_data['machine_name'],
'data-acquia-lift-decision-name' => $all_report_data['decision_name'],
),
'#attached' => array(
'library' => array(
array(
'acquia_lift',
'acquia_lift.help',
),
),
),
);
return $build;
}