You are here

function acquia_lift_report_conversion in Acquia Lift Connector 7

AJAX callback to return the tabular HTML for conversion reports.

The following parameters are supplied within the query string:

  • campaign: the machine name of the campaign
  • decision: the decision name to get data
  • start: (optional) the timestamp to use as start date
  • end: (optional) the timestamp to use as the end date
  • goal: (optional) a goal name to limit results (defaults to all goals)
1 string reference to 'acquia_lift_report_conversion'
acquia_lift_menu in ./acquia_lift.module
Implements hook_menu().

File

./acquia_lift.admin.inc, line 875
acquia_lift.admin.inc Provides functions needed for the admin UI.

Code

function acquia_lift_report_conversion() {
  $params = drupal_get_query_parameters();
  $agent_name = empty($params['campaign']) ? NULL : filter_xss($params['campaign']);
  $options = array();
  $options['decision'] = empty($params['decision']) ? NULL : filter_xss($params['decision']);
  $options['goal'] = empty($params['goal']) ? NULL : filter_xss($params['goal']);
  $options['start'] = empty($params['start']) ? NULL : check_plain($params['start']);
  $options['end'] = empty($params['end']) ? NULL : check_plain($params['end']);
  $agent = personalize_agent_load($agent_name);
  if (!acquia_lift_is_testing_agent($agent)) {
    return array();
  }
  if (is_numeric($options['start'])) {
    $options['start'] = date('Y-m-d', $options['start']);
  }
  if (is_numeric($options['end'])) {
    $options['end'] = date('Y-m-d', $options['end']);
  }
  $reports = array();
  if ($plugin = personalize_agent_load_agent($agent_name)) {
    $reports = $plugin
      ->buildConversionReport($options);
  }
  $reports['#type'] = 'ajax';
  drupal_json_output(drupal_render($reports));
}