Esempio n. 1
0
 public static function getObjectiveMetrics()
 {
     $output = array(esc_html__('Site Usage', 'better-analytics') => array('ga:pageviews' => esc_html__('Page Views', 'better-analytics'), 'ga:bounces' => esc_html__('Bounces', 'better-analytics'), 'ga:sessionDuration' => esc_html__('Session Duration', 'better-analytics')), esc_html__('AdSense', 'better-analytics') => array('ga:adsenseAdsClicks' => esc_html__('AdSense Ads Clicked', 'better-analytics'), 'ga:adsenseAdsViewed' => esc_html__('AdSense Impressions', 'better-analytics'), 'ga:adsenseRevenue' => esc_html__('AdSense Revenue', 'better-analytics')), esc_html__('Ecommerce', 'better-analytics') => array('ga:transactionRevenue' => esc_html__('Ecommerce Revenue', 'better-analytics'), 'ga:transactions' => esc_html__('Ecommerce Transactions', 'better-analytics')), esc_html__('Goals', 'better-analytics') => array());
     if ($goals = DigitalPointBetterAnalytics_Helper_Reporting::getInstance()->getGoals()) {
         $betterAnalyticsOptions = get_option('better_analytics');
         $totals = array();
         if ($goals = DigitalPointBetterAnalytics_Model_Reporting::filterGoalsByProfile($goals, @$betterAnalyticsOptions['property_id'], @$betterAnalyticsOptions['api']['profile'], $totals)) {
             $goalsKey = esc_html__('Goals', 'better-analytics');
             foreach ($goals as $goal) {
                 if (!empty($goal['active'])) {
                     $output[$goalsKey]['ga:goal' . $goal['id'] . 'Completions'] = sprintf(esc_html__('Goal %1$u Completions (%2$s)', 'better-analytics'), $goal['id'], $goal['name']);
                 }
             }
         }
     }
     return $output;
 }
Esempio n. 2
0
 public function actionGoals()
 {
     if (!$this->_assertLinkedAccount()) {
         return;
     }
     if (isset($_REQUEST['action2']) && $_REQUEST['action2'] != -1) {
         $_REQUEST['action'] = $_REQUEST['action2'];
     }
     $betterAnalyticsOptions = get_option('better_analytics');
     $reportingClass = DigitalPointBetterAnalytics_Helper_Reporting::getInstance();
     if (@$_REQUEST['action'] == 'activate' || @$_REQUEST['action'] == 'deactivate') {
         if ($goalId = absint(@$_REQUEST['id'])) {
             check_admin_referer($_REQUEST['action'] . '-goal');
             if ($profile = $reportingClass->getProfileByProfileId($betterAnalyticsOptions['api']['profile'])) {
                 $goal = $reportingClass->patchGoal($profile['accountId'], $profile['webPropertyId'], $profile['id'], $goalId, array('active' => $_REQUEST['action'] == 'activate' ? true : false));
                 $reportingClass->deleteGoalCache();
             }
         }
     } elseif (@$_REQUEST['action'] == 'activate-selected' || @$_REQUEST['action'] == 'deactivate-selected') {
         if (!empty($_REQUEST['checked']) && is_array($_REQUEST['checked'])) {
             $checkIds = array();
             foreach ($_REQUEST['checked'] as $check) {
                 if ($id = absint($check)) {
                     $checkIds[] = $id;
                 }
             }
             if ($checkIds) {
                 check_admin_referer('bulk-goals');
                 if ($profile = $reportingClass->getProfileByProfileId($betterAnalyticsOptions['api']['profile'])) {
                     foreach ($checkIds as $id) {
                         $goal = $reportingClass->patchGoal($profile['accountId'], $profile['webPropertyId'], $profile['id'], $id, array('active' => $_REQUEST['action'] == 'activate-selected' ? true : false));
                     }
                     $reportingClass->deleteGoalCache();
                 }
             }
         }
     }
     global $totals;
     $totals = array();
     $goals = $reportingClass->getGoals();
     $goals = DigitalPointBetterAnalytics_Model_Reporting::filterGoalsByProfile($goals, @$betterAnalyticsOptions['property_id'], @$betterAnalyticsOptions['api']['profile'], $totals);
     $this->_view('goals', array('goals' => $goals));
 }
Esempio n. 3
0
                $goalObject['eventDetails']['eventConditions'][] = array('type' => 'VALUE', 'comparisonType' => $_POST['event_value'], 'comparisonValue' => $_POST['event_value_value']);
            }
            if (count($goalObject['eventDetails']['eventConditions']) == 0) {
                $errorMessage[] = esc_html__('You must specify a Category, Action or Label.', 'better-analytics');
            }
        }
        $reportingClass = DigitalPointBetterAnalytics_Helper_Reporting::getInstance();
        if (!$errorMessage && ($profile = $reportingClass->getProfileByProfileId(@$betterAnalyticsOptions['api']['profile']))) {
            if ($goalId) {
                $goal = $reportingClass->patchGoal($profile['accountId'], $profile['webPropertyId'], $profile['id'], $goalId, $goalObject);
            } else {
                $goal = $reportingClass->insertGoal($profile['accountId'], $profile['webPropertyId'], $profile['id'], $goalObject);
            }
            $reportingClass->deleteGoalCache();
            $goals = $reportingClass->getGoals();
            $goals = DigitalPointBetterAnalytics_Model_Reporting::filterGoalsByProfile($goals, @$betterAnalyticsOptions['property_id'], @$betterAnalyticsOptions['api']['profile'], $totals);
            if ($goalId) {
                /* translators: %1$s = <strong>, %2$s = </strong> */
                $noticeAtTop = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Goal %1$supdated%2$s.'), '<strong>', '</strong>') . '</p></div>';
            } else {
                /* translators: %1$s = <strong>, %2$s = </strong> */
                $noticeAtTop = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Goal %1$screated%2$s.'), '<strong>', '</strong>') . '</p></div>';
            }
        }
    }
}
if (@$_REQUEST['action'] != 'create_edit' || @$_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!empty($errorMessage)) {
        echo '<div class="wrap">';
        foreach ($errorMessage as $error) {
            echo '<div class="error"><p>' . $error . '</p></div>';