function loadGoals($site_id) { $this->goals = array(); for ($i = 1; $i <= $this->numGoals; $i++) { $this->goals[$i] = array('goal_number' => '', 'goal_name' => '', 'goal_group' => '', 'goal_status' => '', 'goal_type' => ''); } $from_db = owa_coreAPI::getSiteSetting($site_id, 'goals'); if ($from_db) { foreach ($from_db as $k => $goal) { if (array_key_exists($k, $this->goals)) { // add to goal array $this->goals[$k] = $goal; // set active goal lists if (array_key_exists('goal_status', $goal) && $goal['goal_status'] === 'active') { // set active goals $this->activeGoals[] = $goal['goal_number']; // set active goal groups if (array_key_exists('goal_group', $goal)) { $this->activeGoalGroups[$goal['goal_group']] = $goal['goal_group']; // set active goals by group $this->activeGoalsByGroup[$goal['goal_group']][] = $goal['goal_number']; } } } } } }
function action() { // action counts $params = array('period' => $this->get('period'), 'startDate' => $this->get('startDate'), 'endDate' => $this->get('endDate'), 'metrics' => 'actions', 'dimensions' => 'actionName', 'siteId' => $this->getParam('siteId'), 'do' => 'getResultSet'); $rs = owa_coreAPI::executeApiCommand($params); //print_r($rs); $this->set('actions', $rs); $rs = owa_coreAPI::executeApiCommand(array('do' => 'getLatestVisits', 'siteId' => $this->getParam('siteId'), 'page' => $this->getParam('page'), 'startDate' => $this->getParam('startDate'), 'endDate' => $this->getParam('endDate'), 'period' => $this->getParam('period'), 'resultsPerPage' => 10)); $this->set('latest_visits', $rs); // set view stuff $this->setSubview('base.reportDashboard'); $this->setTitle('Dashboard'); $metrics = 'visits,uniqueVisitors,pageViews,bounceRate,pagesPerVisit,visitDuration'; if (owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) { $metrics .= ',transactions,transactionRevenue'; } $this->set('metrics', $metrics); }
/** * Pre Action * Current user is fully authenticated and loaded by this point * */ function pre() { $sites = $this->getSitesAllowedForCurrentUser(); $this->set('sites', $sites); $this->set('currentSiteId', $this->getParam('siteId')); // pass full set of params to view $this->data['params'] = $this->params; // set default period if necessary if (!$this->getParam('period') && !$this->getParam('startDate')) { $this->set('is_default_period', true); $period = 'last_seven_days'; $this->params['period'] = $period; } elseif (!$this->getParam('period') && $this->getParam('startDate')) { $period = 'date_range'; $this->params['period'] = $period; } else { $period = $this->getParam('period'); } $this->setPeriod($period); $this->setView('base.report'); $this->setViewMethod('delegate'); $this->dom_id = str_replace('.', '-', $this->getParam('do')); $this->data['dom_id'] = $this->dom_id; $this->data['do'] = $this->getParam('do'); $nav = owa_coreAPI::getGroupNavigation('Reports'); // setup tabs $siteId = $this->get('siteId'); if ($siteId) { $gm = owa_coreAPI::supportClassFactory('base', 'goalManager', $siteId); $tabs = array(); $site_usage = array('tab_label' => 'Site Usage', 'metrics' => 'visits,pagesPerVisit,visitDuration,bounceRate,uniqueVisitors', 'sort' => 'visits-', 'trendchartmetric' => 'visits'); $tabs['site_usage'] = $site_usage; // ecommerce tab if (owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) { $ecommerce = array('tab_label' => 'e-commerce', 'metrics' => 'visits,transactions,transactionRevenue,revenuePerVisit,revenuePerTransaction,ecommerceConversionRate', 'sort' => 'transactionRevenue-', 'trendchartmetric' => 'transactions'); $tabs['ecommerce'] = $ecommerce; } $goal_groups = $gm->getActiveGoalGroups(); if ($goal_groups) { foreach ($goal_groups as $group) { $goal_metrics = 'visits'; $active_goals = $gm->getActiveGoalsByGroup($group); if ($active_goals) { foreach ($active_goals as $goal) { $goal_metrics .= sprintf(',goal%sCompletions', $goal); } } $goal_metrics .= ',goalValueAll'; $goal_group = array('tab_label' => $gm->getGoalGroupLabel($group), 'metrics' => $goal_metrics, 'sort' => 'goalValueAll-', 'trendchartmetric' => 'visits'); $name = 'goal_group_' . $group; $tabs[$name] = $goal_group; } } $this->set('tabs', $tabs); $this->set('tabs_json', json_encode($tabs)); if (!owa_coreAPI::getSiteSetting($this->getParam('siteId'), 'enableEcommerceReporting')) { unset($nav['Ecommerce']); } } //$this->body->set('sub_nav', owa_coreAPI::getNavigation($this->get('nav_tab'), 'sub_nav')); $this->set('top_level_report_nav', $nav); }
/** * Filter function Strips a URL of certain defined session or tracking params * * @return string */ function makeUrlCanonical($url, $site_id = '') { owa_coreAPI::debug('makeUrlCanonical using site_id: ' . $site_id); //remove anchors $pos = strpos($url, '#'); if ($pos) { $url = substr($url, 0, $pos); } $filter_string = owa_coreAPI::getSiteSetting($site_id, 'query_string_filters'); if ($filter_string) { $filters = str_replace(' ', '', $filter_string); $filters = explode(',', $filter_string); } else { $filters = array(); } // merge global filters $global_filters = owa_coreAPI::getSetting('base', 'query_string_filters'); if ($global_filters) { $global_filters = str_replace(' ', '', $global_filters); $global_filters = explode(',', $global_filters); $filters = array_merge($global_filters, $filters); } // OWA specific params to filter array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'source'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'medium'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'campaign'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'ad'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'ad_type'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'overlay'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . 'state'); array_push($filters, owa_coreAPI::getSetting('base', 'ns') . owa_coreAPI::getSetting('base', 'feed_subscription_param')); //print_r($filters); foreach ($filters as $filter => $value) { $url = preg_replace('#\\?' . $value . '=.*$|&' . $value . '=.*$|' . $value . '=.*&#msiU', '', $url); } //check for dangling '?'. this might occure if all params are stripped. // returns last character of string $test = substr($url, -1); // if dangling '?' is found clean up the url by removing it. if ($test == '?') { $url = substr($url, 0, -1); } //check and remove default page $default_page = owa_coreAPI::getSiteSetting($site_id, 'default_page'); if ($default_page) { $default_length = strlen($default_page); if ($default_length) { //test for string $default_test = substr($url, 0 - $default_length, $default_length); if ($default_test === $default_page) { $url = substr($url, 0, 0 - $default_length); } } } // check and remove trailing slash if (substr($url, -1) === '/') { $url = substr($url, 0, -1); } return $url; }