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
?>
"></span>

					</fieldset>

				</td>
			</tr>


			<tr valign="top" class="group_dimensions tab_content">
				<td colspan="2">
					<?php 
printf(__('If you want to track custom dimensions, you need to create the custom dimensions in your %1$sGoogle Analytics account settings%2$s (under %3$sCustom Definitions -> Custom Dimension%4$s).%5$sThey should be scoped as "%3$sHit%4$s".', 'better-analytics'), '<a href="' . esc_url('https://www.google.com/analytics/web/?#management/Settings/') . '" target="_blank">', '</a>', '<strong>', '</strong>', '<br /><br />');
if (!empty($profilePick[@$betterAnalyticsOptions['property_id']])) {
    $dimensions = DigitalPointBetterAnalytics_Helper_Reporting::getInstance()->getDimensions($profilePick[@$betterAnalyticsOptions['property_id']][2], $betterAnalyticsOptions['property_id']);
    $dimensions = DigitalPointBetterAnalytics_Model_Reporting::parseDimensions($dimensions);
} else {
    $dimensions = array();
}
?>
				</td>
			</tr>

			<tr valign="top" class="group_dimensions tab_content">
				<th scope="row"><?php 
esc_html_e('Dimension Indexes', 'better-analytics');
?>
					<p class="description"
					   style="font-weight: normal;">
						<?php 
if (!$dimensions) {
Esempio n. 3
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. 4
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>';
Esempio n. 5
0
    $checks['level'] = @$property['level'];
    $checks['industryVertical'] = @$property['industryVertical'];
    $checks['dimensions'] = $reportingClass->getDimensionsByPropertyId(@$checks['matchingProfile']['accountId'], $betterAnalyticsOptions['property_id'], $dimensions);
}
$checks['licensed'] = DigitalPointBetterAnalytics_Helper_Api::check(true);
if (@$_REQUEST['action'] == 'config') {
    if (!$hasTokens) {
        esc_html_e('You need to first link a Google Analytics account to auto-configure it.', 'better-analytics');
    } elseif (empty($_REQUEST['vertical'])) {
        wp_enqueue_script('chosen_js', BETTER_ANALYTICS_PLUGIN_URL . 'assets/chosen/chosen.jquery.min.js', array(), BETTER_ANALYTICS_VERSION);
        wp_enqueue_style('chosen_css', BETTER_ANALYTICS_PLUGIN_URL . 'assets/chosen/chosen.min.css', array(), BETTER_ANALYTICS_VERSION);
        wp_enqueue_script('better-analytics_admin_js', BETTER_ANALYTICS_PLUGIN_URL . 'assets/digitalpoint/js/admin.js', array(), BETTER_ANALYTICS_VERSION);
        $verticals = $reportingClass->getIndustryVerticals();
        if (!$checks['matchingProfile']) {
            if ($accounts = $reportingClass->getAccounts()) {
                $accounts = DigitalPointBetterAnalytics_Model_Reporting::parseAccounts($accounts, true);
            }
            if (!$accounts) {
                $hasAccounts = false;
            }
        } else {
            $accounts = null;
        }
        echo '<div class="wrap test-configure">

			<h2>' . esc_html__('Auto-Configure', 'better-analytics') . '</h2>';
        if ($hasAccounts) {
            echo '<div class="error"><p>' . esc_html__('Only use this option if you are sure you want to auto-configure everything.', 'better-analytics') . '</p></div>';
            echo '<form action="' . esc_url(menu_page_url('better-analytics_test', false)) . '" method="POST" style="padding:15px">';
            echo '<input type="hidden" name="action" value="config">';
            if ($accounts) {
Esempio n. 6
0
 function widget($args, $instance)
 {
     if (!empty($instance['private'])) {
         if (!DigitalPointBetterAnalytics_Base_Public::getInstance()->canViewReports()) {
             return;
         }
     }
     $stats = get_transient('ba_stats_' . md5(@$instance['metric'] . '-' . @$instance['days'] . '-' . (@$instance['this_page_only'] ? $_SERVER['REQUEST_URI'] : '')));
     if (@$stats === false && !empty($instance['this_page_only'])) {
         $cacheKey = DigitalPointBetterAnalytics_Model_Widget::getStatsWidgetStart($instance);
         $stats = DigitalPointBetterAnalytics_Model_Widget::getStatsWidgetEnd($instance, $cacheKey);
     }
     if (!empty($stats)) {
         $metricTitle = DigitalPointBetterAnalytics_Model_Reporting::getMetricNameByKey($instance['metric']);
         echo $args['before_widget'];
         if (!empty($instance['title'])) {
             echo $args['before_title'];
             echo esc_html($instance['title']);
             echo $args['after_title'];
         }
         printf($instance['format'], $metricTitle, number_format_i18n($stats));
         echo $args['after_widget'];
     }
 }
Esempio n. 7
0
				<h2>' . esc_html__('Experiments', 'better-analytics') . ' <a href="' . add_query_arg(array('action' => 'create_edit'), esc_url(menu_page_url('better-analytics_experiments', false))) . '" class="add-new-h2">' . esc_html__('Add New', 'better-analytics') . '</a>' . '</h2>

		<form method="post" action="' . esc_url(menu_page_url('better-analytics_experiments', false)) . '">
			<input type="hidden" name="page" value="better-analytics_experiments"/>';
        echo $noticeAtTop;
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Experiment %1$sactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate-selected') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Selected experiments %1$sactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'deactivate') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Experiment %1$sdeactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'deactivate-selected') {
            /* translators: %1$s = <strong>, %2$s = </strong> */
            echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf(esc_html__('Selected experiments %1$sdeactivated%2$s.'), '<strong>', '</strong>') . '</p></div>';
        }
        global $totals;
        $experiments = $totals = array();
        if ($profile = $reportingClass->getProfileByProfileId($betterAnalyticsOptions['api']['profile'])) {
            $experiments = DigitalPointBetterAnalytics_Model_Experiments::getAllExperiments($profile['accountId'], $profile['webPropertyId'], $profile['id']);
            $totals = DigitalPointBetterAnalytics_Model_Reporting::getExperimentTotals($experiments);
        }
        $goalTable = new DigitalPointBetterAnalytics_Formatting_ExperimentTable(array('plural' => 'experiments', 'experiments' => $experiments));
        $goalTable->prepare_items();
        $goalTable->views();
        $goalTable->display();
        echo '</form></div>';
    }
}