public function AcquiaLiftAPI::getAudienceReport in Acquia Lift Connector 7.2
File
- includes/
AcquiaLiftAPI.inc, line 487
Class
Code
public function getAudienceReport($name, $audience, $variations, $type, $from, $to, $goal = NULL) {
if ($type == 'target' && count($variations) > 1) {
throw new AcquiaLiftException("Can't retrieve targeting report for more than one variation");
}
if (empty($this->lift_profiles_account_name)) {
throw new AcquiaLiftCredsException('No account name for Lift Profiles configured');
}
$site_name = variable_get('acquia_lift_profiles_site_name', '');
if (empty($site_name)) {
$site_name = 'Drupal';
}
$tz = drupal_get_user_timezone();
$from_datetime = date_create("@{$from}", new DateTimeZone($tz));
$to_datetime = date_create("@{$to}", new DateTimeZone($tz));
$from_str = $from_datetime
->format('Y-m-d');
$to_str = $to_datetime
->format('Y-m-d');
$path = "report/{$type}?account={$this->lift_profiles_account_name}&site={$site_name}&personalization={$name}&audience={$audience}&from={$from_str}&to={$to_str}";
foreach ($variations as $variation) {
$path .= "&variation={$variation}";
}
if (!empty($goal)) {
$path .= "&goal={$goal}";
}
$url = $this
->generateEndpoint($path);
$vars = array(
'name' => $name,
);
$fail_msg = 'Could not retrieve report from Acquia Lift';
return $this
->makeGetRequest($url, $this
->getStandardHeaders(), $fail_msg, $vars);
}