Better Google Analytics - Version 1.2.1

Version Description

Download this release

Release Info

Developer digitalpoint
Plugin Icon 128x128 Better Google Analytics
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

better-analytics.php CHANGED
@@ -7,7 +7,7 @@
7
  Plugin Name: Better Analytics
8
  Plugin URI: https://marketplace.digitalpoint.com/better-analytics.3354/item
9
  Description: Adds Google Universal Analytics code to your WordPress site. Options to track most everything (social button interactions, advertising clicks, emails sent/opened, YouTube video engagement, custom dimension tracking of authors/categories, etc.) Integrates with API for reports/charts on dashboard, heat maps and real-time traffic tracking.
10
- Version: 1.2.0
11
  Author: Digital Point
12
  Author URI: https://www.digitalpoint.com/
13
  License: GPLv2
@@ -23,7 +23,7 @@ if (!function_exists('add_action'))
23
  exit;
24
  }
25
 
26
- define('BETTER_ANALYTICS_VERSION', '1.2.0');
27
  define('BETTER_ANALYTICS_MINIMUM_WP_VERSION', '3.8'); // Dashicons: https://codex.wordpress.org/Function_Reference/add_menu_page
28
  define('BETTER_ANALYTICS_PRODUCT_URL', 'https://marketplace.digitalpoint.com/better-analytics.3354/item');
29
  define('BETTER_ANALYTICS_PRO_PRODUCT_URL', 'https://marketplace.digitalpoint.com/better-analytics-pro.3355/item');
7
  Plugin Name: Better Analytics
8
  Plugin URI: https://marketplace.digitalpoint.com/better-analytics.3354/item
9
  Description: Adds Google Universal Analytics code to your WordPress site. Options to track most everything (social button interactions, advertising clicks, emails sent/opened, YouTube video engagement, custom dimension tracking of authors/categories, etc.) Integrates with API for reports/charts on dashboard, heat maps and real-time traffic tracking.
10
+ Version: 1.2.1
11
  Author: Digital Point
12
  Author URI: https://www.digitalpoint.com/
13
  License: GPLv2
23
  exit;
24
  }
25
 
26
+ define('BETTER_ANALYTICS_VERSION', '1.2.1');
27
  define('BETTER_ANALYTICS_MINIMUM_WP_VERSION', '3.8'); // Dashicons: https://codex.wordpress.org/Function_Reference/add_menu_page
28
  define('BETTER_ANALYTICS_PRODUCT_URL', 'https://marketplace.digitalpoint.com/better-analytics.3354/item');
29
  define('BETTER_ANALYTICS_PRO_PRODUCT_URL', 'https://marketplace.digitalpoint.com/better-analytics-pro.3355/item');
library/DigitalPointBetterAnalytics/Base/Admin.php CHANGED
@@ -59,7 +59,7 @@ class DigitalPointBetterAnalytics_Base_Admin
59
  add_action('admin_notices', array($this, 'not_configured' ) );
60
  }
61
 
62
- if (strpos(@$_SERVER['REQUEST_URI'], 'page=better-analytics') !== false || @!$betterAnalyticsOptions['hide_api_message'])
63
  {
64
  if (!get_site_option('ba_site_tokens') && !get_option('ba_tokens'))
65
  {
@@ -139,11 +139,13 @@ class DigitalPointBetterAnalytics_Base_Admin
139
 
140
  $links['settings'] = '<a href="' . esc_url(menu_page_url('better-analytics', false)) . '">' . esc_html__('Settings' , 'better-analytics').'</a>';
141
 
 
 
142
  krsort($links);
143
  end($links);
144
  $key = key($links);
145
- $links[$key] .= '<p class="' . (DigitalPointBetterAnalytics_Helper_Api::$installed && @$betterAnalyticsInternal['v'] && @$betterAnalyticsInternal['l'] == DigitalPointBetterAnalytics_Helper_Api::$version ? 'green' : 'orange') . '"> ' .
146
- (DigitalPointBetterAnalytics_Helper_Api::$installed ?
147
  (@$betterAnalyticsInternal['v'] ?
148
  (@$betterAnalyticsInternal['l'] != DigitalPointBetterAnalytics_Helper_Api::$version ?
149
  sprintf('<a href="%1$s" target="_blank">%2$s</a><br />%3$s %4$s<br />%5$s %6$s',
@@ -201,10 +203,15 @@ class DigitalPointBetterAnalytics_Base_Admin
201
  $betterAnalyticsOptions = get_option('better_analytics');
202
  $currentUser = wp_get_current_user();
203
 
204
- if (!empty($betterAnalyticsOptions['javascript']['use_in_admin']) && !empty($betterAnalyticsOptions['roles_no_track']) && !array_intersect((array)$currentUser->roles, (array)@$betterAnalyticsOptions['roles_no_track']))
205
  {
206
- DigitalPointBetterAnalytics_Base_Public::getInstance()->insert_code();
207
- include(BETTER_ANALYTICS_PLUGIN_DIR . 'js/universal.php');
 
 
 
 
 
208
  }
209
  }
210
 
@@ -460,7 +467,7 @@ class DigitalPointBetterAnalytics_Base_Admin
460
  $links['support'] = '<a href="' . esc_url(BETTER_ANALYTICS_SUPPORT_URL ) . '" title="' . esc_attr( esc_html__( 'Visit Support Forum', 'better-analytics' ) ) . '">' . esc_html__( 'Support', 'better-analytics' ) . '</a>';
461
 
462
  $betterAnalyticsInternal = get_transient('ba_int');
463
- if (DigitalPointBetterAnalytics_Helper_Api::$installed && empty($betterAnalyticsInternal['v']))
464
  {
465
  $links['verify_domain'] = '<a href="' . esc_url('https://forums.digitalpoint.com/marketplace/domain-verification#utm_source=admin_plugins&utm_medium=wordpress&utm_campaign=plugin') . '" target="_blank">' . esc_html__( 'Verify Domain', 'better-analytics' ) . '</a>';
466
  }
59
  add_action('admin_notices', array($this, 'not_configured' ) );
60
  }
61
 
62
+ if (strpos(@$_SERVER['REQUEST_URI'], 'page=better-analytics') !== false || empty($betterAnalyticsOptions['hide_api_message']))
63
  {
64
  if (!get_site_option('ba_site_tokens') && !get_option('ba_tokens'))
65
  {
139
 
140
  $links['settings'] = '<a href="' . esc_url(menu_page_url('better-analytics', false)) . '">' . esc_html__('Settings' , 'better-analytics').'</a>';
141
 
142
+ $installed = isset(DigitalPointBetterAnalytics_Helper_Api::$version) && DigitalPointBetterAnalytics_Helper_Api::$version;
143
+
144
  krsort($links);
145
  end($links);
146
  $key = key($links);
147
+ $links[$key] .= '<p class="' . ($installed && @$betterAnalyticsInternal['v'] && @$betterAnalyticsInternal['l'] == DigitalPointBetterAnalytics_Helper_Api::$version ? 'green' : 'orange') . '"> ' .
148
+ ($installed ?
149
  (@$betterAnalyticsInternal['v'] ?
150
  (@$betterAnalyticsInternal['l'] != DigitalPointBetterAnalytics_Helper_Api::$version ?
151
  sprintf('<a href="%1$s" target="_blank">%2$s</a><br />%3$s %4$s<br />%5$s %6$s',
203
  $betterAnalyticsOptions = get_option('better_analytics');
204
  $currentUser = wp_get_current_user();
205
 
206
+ if (!empty($betterAnalyticsOptions['javascript']['use_in_admin']))
207
  {
208
+ if (empty($betterAnalyticsOptions['roles_no_track']) || !array_intersect((array)$currentUser->roles, (array)@$betterAnalyticsOptions['roles_no_track']))
209
+ {
210
+ echo 'YYY';
211
+
212
+ DigitalPointBetterAnalytics_Base_Public::getInstance()->insert_code();
213
+ include(BETTER_ANALYTICS_PLUGIN_DIR . 'js/universal.php');
214
+ }
215
  }
216
  }
217
 
467
  $links['support'] = '<a href="' . esc_url(BETTER_ANALYTICS_SUPPORT_URL ) . '" title="' . esc_attr( esc_html__( 'Visit Support Forum', 'better-analytics' ) ) . '">' . esc_html__( 'Support', 'better-analytics' ) . '</a>';
468
 
469
  $betterAnalyticsInternal = get_transient('ba_int');
470
+ if (isset(DigitalPointBetterAnalytics_Helper_Api::$version) && DigitalPointBetterAnalytics_Helper_Api::$version && empty($betterAnalyticsInternal['v']))
471
  {
472
  $links['verify_domain'] = '<a href="' . esc_url('https://forums.digitalpoint.com/marketplace/domain-verification#utm_source=admin_plugins&utm_medium=wordpress&utm_campaign=plugin') . '" target="_blank">' . esc_html__( 'Verify Domain', 'better-analytics' ) . '</a>';
473
  }
library/DigitalPointBetterAnalytics/Base/Public.php CHANGED
@@ -332,8 +332,10 @@ class DigitalPointBetterAnalytics_Base_Public
332
 
333
  public function insert_code()
334
  {
 
 
335
  echo "<!-- This site uses the Better Analytics plugin. " . BETTER_ANALYTICS_PRODUCT_URL . " -->
336
- <script type='text/javascript' src='" . plugins_url('better-analytics/js/loader.php') . "?ver=" . BETTER_ANALYTICS_VERSION . ".js' ></script>";
337
  }
338
 
339
 
@@ -452,7 +454,7 @@ class DigitalPointBetterAnalytics_Base_Public
452
 
453
  if (is_feed() && $betterAnalyticsOptions['source_link']['rss'])
454
  {
455
- if ($betterAnalyticsOptions['$betterAnalyticsOptions'] == 'anchor')
456
  {
457
  $urlDelimiter = '#';
458
  }
332
 
333
  public function insert_code()
334
  {
335
+ $betterAnalyticsOptions = get_option('better_analytics');
336
+
337
  echo "<!-- This site uses the Better Analytics plugin. " . BETTER_ANALYTICS_PRODUCT_URL . " -->
338
+ <script type='text/javascript' src='" . plugins_url('better-analytics/js/loader.php') . "?ver=" . BETTER_ANALYTICS_VERSION . ".js' ". (!empty($betterAnalyticsOptions['javascript']['defer']) ? 'defer="defer" ' : '') . "></script>";
339
  }
340
 
341
 
454
 
455
  if (is_feed() && $betterAnalyticsOptions['source_link']['rss'])
456
  {
457
+ if ($betterAnalyticsOptions['campaign_tracking'] == 'anchor')
458
  {
459
  $urlDelimiter = '#';
460
  }
library/DigitalPointBetterAnalytics/Helper/Api.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  class DigitalPointBetterAnalytics_Helper_Api
4
  {
5
- public static $installed = false;
6
-
7
  public static $version = null;
8
 
9
  public static function check($force = false)
2
 
3
  class DigitalPointBetterAnalytics_Helper_Api
4
  {
 
 
5
  public static $version = null;
6
 
7
  public static function check($force = false)
library/DigitalPointBetterAnalytics/Helper/Reporting/Abstract.php CHANGED
@@ -5,7 +5,6 @@ abstract class DigitalPointBetterAnalytics_Helper_Reporting_Abstract
5
  protected static $_instance;
6
 
7
  protected static $_oAuthEndpoint = 'https://accounts.google.com/o/oauth2/';
8
- // TODO: delete -- protected static $_dataEndpoint = 'https://www.googleapis.com/analytics/v3/data/ga';
9
 
10
  protected static $_dataEndpoint = 'https://analyticsreporting.googleapis.com/v4/reports:batchGet';
11
 
@@ -968,55 +967,6 @@ abstract class DigitalPointBetterAnalytics_Helper_Reporting_Abstract
968
  return $outputData;
969
  }
970
 
971
- /*
972
- public function getChartOld($endDaysAgo, $days, $metric, $dimension, $segment = null)
973
- {
974
- $filters = null;
975
-
976
- if (strpos($metric, '|'))
977
- {
978
- $split = explode('|', $metric);
979
- $metric = $split[0];
980
- $filters = $split[1];
981
- }
982
-
983
- $cacheKey = $this->getData(($endDaysAgo + $days - 1) . 'daysAgo', $endDaysAgo . 'daysAgo', $metric, $dimension, ($dimension == 'ga:date' ? $dimension : '-' . $metric), $filters, $segment);
984
- $data = $this->getResults($cacheKey);
985
-
986
- if ($dimension == 'ga:date')
987
- {
988
- return $data['rows'];
989
- }
990
-
991
- $chartData = $outputData = array();
992
- if (!empty($data['rows']))
993
- {
994
- foreach($data['rows'] as $row)
995
- {
996
- $split = explode(',', $row[0]);
997
- foreach ($split as $name)
998
- {
999
- $name = trim($name);
1000
- @$chartData[$name] += $row[1];
1001
- }
1002
- }
1003
- }
1004
-
1005
- arsort($chartData);
1006
- if ($chartData)
1007
- {
1008
- foreach ($chartData as $name => $value)
1009
- {
1010
- $outputData[] = array((string)$name, $value);
1011
- }
1012
- }
1013
-
1014
- return $outputData;
1015
- }
1016
- */
1017
-
1018
-
1019
-
1020
  public function getData($startDate, $endDate, $metrics, array $dimensions = array(), array $orderBys = array(), array $dimensionFilterClauses = array(), array $metricFilterClauses = array(), array $segments = array(), $samplingLevel = null, $pageSize = 10000, $output = 'json', $quotaUser = null)
1021
  {
1022
  $viewId = $this->_getOption('apiProfile');
5
  protected static $_instance;
6
 
7
  protected static $_oAuthEndpoint = 'https://accounts.google.com/o/oauth2/';
 
8
 
9
  protected static $_dataEndpoint = 'https://analyticsreporting.googleapis.com/v4/reports:batchGet';
10
 
967
  return $outputData;
968
  }
969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  public function getData($startDate, $endDate, $metrics, array $dimensions = array(), array $orderBys = array(), array $dimensionFilterClauses = array(), array $metricFilterClauses = array(), array $segments = array(), $samplingLevel = null, $pageSize = 10000, $output = 'json', $quotaUser = null)
971
  {
972
  $viewId = $this->_getOption('apiProfile');
library/DigitalPointBetterAnalytics/Model/Widget.php CHANGED
@@ -66,7 +66,7 @@ class DigitalPointBetterAnalytics_Model_Widget
66
 
67
  public static function getStatsWidgetData($settings = null)
68
  {
69
- if (!settings)
70
  {
71
  $statsWidget = new DigitalPointBetterAnalytics_Widget_Stats();
72
  $settings = $statsWidget->get_settings();
66
 
67
  public static function getStatsWidgetData($settings = null)
68
  {
69
+ if (!$settings)
70
  {
71
  $statsWidget = new DigitalPointBetterAnalytics_Widget_Stats();
72
  $settings = $statsWidget->get_settings();
library/DigitalPointBetterAnalytics/ViewAdmin/config.php CHANGED
@@ -1070,12 +1070,19 @@
1070
 
1071
  <br />
1072
  <label for="ba_use_in_admin">
1073
- <input name="better_analytics[javascript][use_in_admin]" type="checkbox" id="ba_use_in_admin" value="1" <?php checked('1', @$betterAnalyticsOptions['javascript']['use_in_admin'] ); ?>>
1074
  <?php esc_html_e('Use In Staff Area (wp-admin)', 'better-analytics');?></label>
 
 
 
 
 
 
1075
  </fieldset>
1076
  </td>
1077
  </tr>
1078
 
 
1079
  <tr valign="top" class="group_advanced tab_content">
1080
  <th scope="row"><?php esc_html_e('When To Run Analytics Code', 'better-analytics');?></th>
1081
  <td>
1070
 
1071
  <br />
1072
  <label for="ba_use_in_admin">
1073
+ <input name="better_analytics[javascript][use_in_admin]" type="checkbox" id="ba_use_in_admin" value="1" <?php checked('1', !empty($betterAnalyticsOptions['javascript']['use_in_admin']) ? $betterAnalyticsOptions['javascript']['use_in_admin'] : '' ); ?>>
1074
  <?php esc_html_e('Use In Staff Area (wp-admin)', 'better-analytics');?></label>
1075
+
1076
+ <br />
1077
+ <label for="ba_defer">
1078
+ <input name="better_analytics[javascript][defer]" type="checkbox" id="ba_defer" value="1" <?php checked('1', !empty($betterAnalyticsOptions['javascript']['defer']) ? $betterAnalyticsOptions['javascript']['defer'] : '' ); ?>>
1079
+ <?php esc_html_e('Defer JavaScript loading', 'better-analytics');?></label>
1080
+
1081
  </fieldset>
1082
  </td>
1083
  </tr>
1084
 
1085
+
1086
  <tr valign="top" class="group_advanced tab_content">
1087
  <th scope="row"><?php esc_html_e('When To Run Analytics Code', 'better-analytics');?></th>
1088
  <td>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: digitalpoint
3
  Tags: analytics, google analytics, universal analytics, statistics, tracking, code, dashboard, analytics dashboard, google analytics dashboard, google analytics plugin, google analytics widget, reports, charts, multisite, api, stats, web stats, visits, javascript, pageviews, marketing, widget, realtime, real time, youtube, outbrain, taboola, adsense, twitter, pinterest, linkedin, facebook, google, digitalpoint, ab testing, ab tests, split testing, google analytics content experiments, content experiments
4
  Donate link: https://marketplace.digitalpoint.com/better-analytics.3354/item#utm_source=readme&utm_medium=wordpress&utm_campaign=plugin
5
  Requires at least: 3.8
6
- Tested up to: 4.7.3
7
- Stable tag: 1.2.0
8
  License: GPLv2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -21,7 +21,7 @@ In addition, Better Google Analytics makes A/B (split) testing a breeze (no code
21
  >
22
  > The Better Google Analytics plugin can automatically configure your Google Analytics account to maximize what you can track with the minimum amount of effort. Can automatically set various options on your Google Analytics account on your behalf as well as create custom dimensions and map them to where they need to go. If you are setting up a brand new site, this plugin can even create a brand new Web Property within your selected Google Analytics account if you wish. All with a single click.
23
 
24
- Better Google Analytics utilizes all the latest and greatest features of Google Analytics (Universal analytics, user-ID session unification, event tracking, campaign tracking, custom dimensions, server-side tracking, social engagement tracking, remarketing, etc.)
25
 
26
  > <strong>Google Analytics Account Management</strong><br>
27
  >
@@ -201,6 +201,14 @@ Thank you to all the individuals who have contributed translations for Better Go
201
  26. Advanced settings allow you to fine tune how the system works with Google Analytics.
202
 
203
  == Changelog ==
 
 
 
 
 
 
 
 
204
  = 1.2.0 =
205
  * Better checking for null settings
206
  * Updated Google Analytics Reporting API library to utilize V4
3
  Tags: analytics, google analytics, universal analytics, statistics, tracking, code, dashboard, analytics dashboard, google analytics dashboard, google analytics plugin, google analytics widget, reports, charts, multisite, api, stats, web stats, visits, javascript, pageviews, marketing, widget, realtime, real time, youtube, outbrain, taboola, adsense, twitter, pinterest, linkedin, facebook, google, digitalpoint, ab testing, ab tests, split testing, google analytics content experiments, content experiments
4
  Donate link: https://marketplace.digitalpoint.com/better-analytics.3354/item#utm_source=readme&utm_medium=wordpress&utm_campaign=plugin
5
  Requires at least: 3.8
6
+ Tested up to: 4.7.4
7
+ Stable tag: 1.2.1
8
  License: GPLv2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
21
  >
22
  > The Better Google Analytics plugin can automatically configure your Google Analytics account to maximize what you can track with the minimum amount of effort. Can automatically set various options on your Google Analytics account on your behalf as well as create custom dimensions and map them to where they need to go. If you are setting up a brand new site, this plugin can even create a brand new Web Property within your selected Google Analytics account if you wish. All with a single click.
23
 
24
+ Better Google Analytics utilizes all the latest and greatest features of Google Analytics (Universal analytics, user-ID session unification, event tracking, campaign tracking, custom dimensions, server-side tracking, social engagement tracking, remarketing, etc.) Additionally, Better Analytics can track users who are visiting AMP (Accelerated Mobile Pages) on your site.
25
 
26
  > <strong>Google Analytics Account Management</strong><br>
27
  >
201
  26. Advanced settings allow you to fine tune how the system works with Google Analytics.
202
 
203
  == Changelog ==
204
+ = .1.2.1 =
205
+ * Fixed bug with RSS link tracking
206
+ * Fixed bug with widget
207
+ * Fixed issue where Google Analytics code might not be used in certain cases in the wp-admin area
208
+ * New Advanced Setting: Defer JavaScript loading
209
+ * Fixed issue where an old version of the Pro version installed with the new version of the Free version could cause an issue
210
+ * Made some minor changes for better PHP 7.1 compatibility
211
+
212
  = 1.2.0 =
213
  * Better checking for null settings
214
  * Updated Google Analytics Reporting API library to utilize V4