Google Analytics - Version 2.3.5

Version Description

  • Updated analytics feature.
  • Add filter to show 30 days worth of data.
  • Add Top 10 Pages/Posts by Pageviews.
  • For all charts, add a link that allows user to go to Google Analytics page where the data is from.
  • Improved debug messaging.
  • Removed Trending Contents feature.
  • Removed comparison line in chart.
Download this release

Release Info

Developer ShareThis
Plugin Icon wp plugin Google Analytics
Version 2.3.5
Comparing to
See all releases

Code changes from version 2.2.5 to 2.3.5

class/Ga_Admin.php CHANGED
@@ -17,7 +17,6 @@ class Ga_Admin {
17
  const GA_SHARETHIS_PROPERTY_SECRET = 'googleanalytics_sherethis_property_secret';
18
  const GA_SHARETHIS_VERIFICATION_RESULT = 'googleanalytics_sherethis_verification_result';
19
  const MIN_WP_VERSION = '3.8';
20
- const GA_SHARETHIS_TRENDING_CONTENT_PLUGIN_VERSION = '2.1';
21
  const GA_SHARETHIS_API_ALIAS = 'sharethis';
22
  const GA_DISABLE_ALL_FEATURES = 'googleanalytics_disable_all_features';
23
  const GA_HEARTBEAT_API_CACHE_UPDATE = false;
@@ -203,43 +202,10 @@ class Ga_Admin {
203
  if ( current_user_can( 'manage_options' ) ) {
204
  add_menu_page( 'Google Analytics', 'Google Analytics', 'manage_options', 'googleanalytics', 'Ga_Admin::statistics_page_googleanalytics', 'dashicons-chart-line', 1000 );
205
  add_submenu_page( 'googleanalytics', 'Google Analytics', __( 'Dashboard' ), 'manage_options', 'googleanalytics', 'Ga_Admin::statistics_page_googleanalytics' );
206
- add_submenu_page( 'googleanalytics', 'Google Analytics', __( 'Trending Content' ), 'manage_options', 'googleanalytics/trending', 'Ga_Admin::trending_page_googleanalytics' );
207
  add_submenu_page( 'googleanalytics', 'Google Analytics', __( 'Settings' ), 'manage_options', 'googleanalytics/settings', 'Ga_Admin::options_page_googleanalytics' );
208
  }
209
  }
210
 
211
- /**
212
- * Prepares and displays plugin's trending content page.
213
- */
214
- public static function trending_page_googleanalytics() {
215
-
216
- if ( ! Ga_Helper::is_wp_version_valid() || ! Ga_Helper::is_php_version_valid() ) {
217
- return false;
218
- }
219
- $data = Ga_Sharethis::create_sharethis_options( self::api_client( self::GA_SHARETHIS_API_ALIAS ) );
220
-
221
- Ga_Sharethis::sharethis_installation_verification( self::api_client( self::GA_SHARETHIS_API_ALIAS ) );
222
-
223
- $alerts = Ga_Sharethis::load_sharethis_trending_alerts( self::api_client( self::GA_SHARETHIS_API_ALIAS ) );
224
- // Handle invitation result
225
- $data = Ga_Helper::handle_url_message( $data );
226
- if ( Ga_Helper::is_wp_old() ) {
227
- self::display_api_errors( self::GA_SHARETHIS_API_ALIAS );
228
- }
229
- Ga_View_Core::load(
230
- 'trending',
231
- array(
232
- 'data' => $data,
233
- 'alerts' => $alerts,
234
- 'tooltip' => Ga_Helper::get_tooltip(),
235
- 'errors' => self::api_client( self::GA_SHARETHIS_API_ALIAS )->get_errors(),
236
- )
237
- );
238
- if ( ! Ga_Helper::is_wp_old() ) {
239
- self::display_api_errors( self::GA_SHARETHIS_API_ALIAS );
240
- }
241
- }
242
-
243
  /**
244
  * Prepares and displays plugin's stats page.
245
  */
@@ -311,6 +277,8 @@ class Ga_Admin {
311
  $data['auth_button'] = self::get_auth_button( 'auth' );
312
  }
313
  $data['debug_modal'] = self::get_debug_modal();
 
 
314
  if ( ! empty( $_GET['err'] ) ) { // WPCS: CSRF ok.
315
  switch ( $_GET['err'] ) { // WPCS: CSRF ok.
316
  case 1:
@@ -473,10 +441,6 @@ class Ga_Admin {
473
  Ga_View_Core::load( 'ga_notice', [ 'url' => $url ] );
474
  }
475
 
476
- if ( ! empty( $_GET['settings-updated'] ) && Ga_Helper::is_plugin_page() ) { // WPCS: CSRF ok.
477
- echo wp_kses_post( Ga_Helper::ga_wp_notice( __( 'Settings saved' ), 'success' ) );
478
- }
479
-
480
  if ( Ga_Helper::get_option( self::GA_DISABLE_ALL_FEATURES ) ) {
481
  echo wp_kses_post(
482
  Ga_Helper::ga_wp_notice(
@@ -533,6 +497,7 @@ class Ga_Admin {
533
  add_action( 'admin_enqueue_scripts', 'Ga_Admin::enqueue_scripts' );
534
  add_action( 'wp_dashboard_setup', 'Ga_Admin::add_dashboard_device_widget' );
535
  add_action( 'wp_ajax_ga_ajax_data_change', 'Ga_Admin::ga_ajax_data_change' );
 
536
  add_action( 'admin_notices', 'Ga_Admin::admin_notice_googleanalytics' );
537
  add_action( 'heartbeat_tick', 'Ga_Admin::run_heartbeat_jobs' );
538
  add_action( 'wp_ajax_googleanalytics_send_debug_email', 'Ga_SupportLogger::send_email' );
@@ -666,6 +631,7 @@ class Ga_Admin {
666
  }
667
 
668
  $tmp['webProperties'][] = array(
 
669
  'webPropertyId' => $property['id'],
670
  'name' => $property['name'],
671
  'profiles' => $profiles,
@@ -720,7 +686,8 @@ class Ga_Admin {
720
  public static function generate_stats_data() {
721
  $selected = Ga_Helper::get_selected_account_data( true );
722
 
723
- $query_params = Ga_Stats::get_query( 'main_chart', $selected['view_id'] );
 
724
  $stats_data = self::api_client()->call(
725
  'ga_api_data',
726
  [ $query_params ]
@@ -740,7 +707,7 @@ class Ga_Admin {
740
  unset( $chart['date'] );
741
  $labels = array(
742
  'thisWeek' => date( 'M d, Y', strtotime( '-6 day', $last_chart_date ) ) . ' - ' . date( 'M d, Y', $last_chart_date ),
743
- 'lastWeek' => date( 'M d, Y', strtotime( '-13 day', $last_chart_date ) ) . ' - ' . date( 'M d, Y', strtotime( '-7 day', $last_chart_date ) ),
744
  );
745
  $sources = ! empty( $sources_data ) ? Ga_Stats::get_sources( $sources_data->getData() ) : array();
746
 
@@ -775,8 +742,18 @@ class Ga_Admin {
775
 
776
  return Ga_View_Core::load(
777
  'ga_debug_modal',
778
- [ 'debug_info' => Ga_SupportLogger::$debug_info ],
779
  true
780
  );
781
  }
 
 
 
 
 
 
 
 
 
 
782
  }
17
  const GA_SHARETHIS_PROPERTY_SECRET = 'googleanalytics_sherethis_property_secret';
18
  const GA_SHARETHIS_VERIFICATION_RESULT = 'googleanalytics_sherethis_verification_result';
19
  const MIN_WP_VERSION = '3.8';
 
20
  const GA_SHARETHIS_API_ALIAS = 'sharethis';
21
  const GA_DISABLE_ALL_FEATURES = 'googleanalytics_disable_all_features';
22
  const GA_HEARTBEAT_API_CACHE_UPDATE = false;
202
  if ( current_user_can( 'manage_options' ) ) {
203
  add_menu_page( 'Google Analytics', 'Google Analytics', 'manage_options', 'googleanalytics', 'Ga_Admin::statistics_page_googleanalytics', 'dashicons-chart-line', 1000 );
204
  add_submenu_page( 'googleanalytics', 'Google Analytics', __( 'Dashboard' ), 'manage_options', 'googleanalytics', 'Ga_Admin::statistics_page_googleanalytics' );
 
205
  add_submenu_page( 'googleanalytics', 'Google Analytics', __( 'Settings' ), 'manage_options', 'googleanalytics/settings', 'Ga_Admin::options_page_googleanalytics' );
206
  }
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  /**
210
  * Prepares and displays plugin's stats page.
211
  */
277
  $data['auth_button'] = self::get_auth_button( 'auth' );
278
  }
279
  $data['debug_modal'] = self::get_debug_modal();
280
+ $data['debug_info'] = Ga_SupportLogger::$debug_info;
281
+
282
  if ( ! empty( $_GET['err'] ) ) { // WPCS: CSRF ok.
283
  switch ( $_GET['err'] ) { // WPCS: CSRF ok.
284
  case 1:
441
  Ga_View_Core::load( 'ga_notice', [ 'url' => $url ] );
442
  }
443
 
 
 
 
 
444
  if ( Ga_Helper::get_option( self::GA_DISABLE_ALL_FEATURES ) ) {
445
  echo wp_kses_post(
446
  Ga_Helper::ga_wp_notice(
497
  add_action( 'admin_enqueue_scripts', 'Ga_Admin::enqueue_scripts' );
498
  add_action( 'wp_dashboard_setup', 'Ga_Admin::add_dashboard_device_widget' );
499
  add_action( 'wp_ajax_ga_ajax_data_change', 'Ga_Admin::ga_ajax_data_change' );
500
+ add_action( 'wp_ajax_ga_ajax_hide_review', 'Ga_Admin::ga_ajax_hide_review' );
501
  add_action( 'admin_notices', 'Ga_Admin::admin_notice_googleanalytics' );
502
  add_action( 'heartbeat_tick', 'Ga_Admin::run_heartbeat_jobs' );
503
  add_action( 'wp_ajax_googleanalytics_send_debug_email', 'Ga_SupportLogger::send_email' );
631
  }
632
 
633
  $tmp['webProperties'][] = array(
634
+ 'internalWebPropertyId' => $property['internalWebPropertyId'],
635
  'webPropertyId' => $property['id'],
636
  'name' => $property['name'],
637
  'profiles' => $profiles,
686
  public static function generate_stats_data() {
687
  $selected = Ga_Helper::get_selected_account_data( true );
688
 
689
+ $query_params = isset( $_GET['th'] ) ? Ga_Stats::get_query( 'main_chart', $selected['view_id'], '30daysAgo' ) : Ga_Stats::get_query( 'main_chart', $selected['view_id'] );
690
+
691
  $stats_data = self::api_client()->call(
692
  'ga_api_data',
693
  [ $query_params ]
707
  unset( $chart['date'] );
708
  $labels = array(
709
  'thisWeek' => date( 'M d, Y', strtotime( '-6 day', $last_chart_date ) ) . ' - ' . date( 'M d, Y', $last_chart_date ),
710
+ 'thisMonth' => date( 'M d, Y', strtotime( '-29 day', $last_chart_date ) ) . ' - ' . date( 'M d, Y', $last_chart_date ),
711
  );
712
  $sources = ! empty( $sources_data ) ? Ga_Stats::get_sources( $sources_data->getData() ) : array();
713
 
742
 
743
  return Ga_View_Core::load(
744
  'ga_debug_modal',
745
+ [ 'debug_info' => Ga_SupportLogger::$debug_info, 'debug_help_message' => Ga_SupportLogger::$debug_help_message ],
746
  true
747
  );
748
  }
749
+
750
+ public static function ga_ajax_hide_review( $post ) {
751
+ $error = 0;
752
+
753
+ if ( Ga_Controller_Core::verify_nonce( 'ga_ajax_data_change' ) ) {
754
+ update_option('googleanalytics-hide-review', true);
755
+ }
756
+
757
+ wp_send_json_success('hidden');
758
+ }
759
  }
class/Ga_Helper.php CHANGED
@@ -6,7 +6,6 @@ class Ga_Helper {
6
  const GA_DEFAULT_WEB_ID = 'UA-0000000-0';
7
  const GA_STATISTICS_PAGE_URL = 'admin.php?page=googleanalytics';
8
  const GA_SETTINGS_PAGE_URL = 'admin.php?page=googleanalytics/settings';
9
- const GA_TRENDING_PAGE_URL = 'admin.php?page=googleanalytics/trending';
10
  const DASHBOARD_PAGE_NAME = 'dashboard';
11
  const PHP_VERSION_REQUIRED = '5.2.17';
12
  const GA_WP_MODERN_VERSION = '4.1';
@@ -44,10 +43,8 @@ class Ga_Helper {
44
  if ( is_admin() ) {
45
  Ga_Admin::add_filters();
46
  Ga_Admin::add_actions();
 
47
 
48
- if ( false === self::is_trending_page() ) {
49
- Ga_Admin::init_oauth();
50
- }
51
 
52
  $admin_controller = new Ga_Admin_Controller();
53
  $admin_controller->handle_actions();
@@ -74,16 +71,6 @@ class Ga_Helper {
74
  return preg_match( '/' . self::DASHBOARD_PAGE_NAME . '/', $site->base );
75
  }
76
 
77
- /**
78
- * Checks if current page is a trending page.
79
- * @return number
80
- */
81
- public static function is_trending_page() {
82
- $site_uri = urldecode( basename( $_SERVER['REQUEST_URI'] ) );
83
-
84
- return preg_match( '/' . preg_quote( self::GA_TRENDING_PAGE_URL, '/' ) . '/', $site_uri, $matches ) === 1;
85
- }
86
-
87
  /**
88
  * Check whether the plugin is configured.
89
  *
@@ -542,21 +529,12 @@ class Ga_Helper {
542
  return ( get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_ID ) && get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_SECRET ) );
543
  }
544
 
545
- public static function is_plugin_version_with_trending_content() {
546
- return ( version_compare( get_option( Ga_Admin::GA_VERSION_OPTION_NAME ), Ga_Admin::GA_SHARETHIS_TRENDING_CONTENT_PLUGIN_VERSION, '>=' ) );
547
- }
548
-
549
  public static function should_create_sharethis_property() {
550
- return ( self::is_plugin_version_with_trending_content() && self::are_features_enabled() && !self::are_sharethis_properties_set() );
551
  }
552
 
553
  public static function should_verify_sharethis_installation() {
554
- return ( self::is_plugin_version_with_trending_content() && self::are_features_enabled() && self::are_sharethis_properties_ready_to_verify() );
555
- }
556
-
557
- public static function should_load_trending_alerts() {
558
- //return ( self::is_plugin_version_with_trending_content() && self::are_features_enabled() && self::are_sharethis_properties_verified() );
559
- return true;
560
  }
561
 
562
  public static function get_tooltip() {
6
  const GA_DEFAULT_WEB_ID = 'UA-0000000-0';
7
  const GA_STATISTICS_PAGE_URL = 'admin.php?page=googleanalytics';
8
  const GA_SETTINGS_PAGE_URL = 'admin.php?page=googleanalytics/settings';
 
9
  const DASHBOARD_PAGE_NAME = 'dashboard';
10
  const PHP_VERSION_REQUIRED = '5.2.17';
11
  const GA_WP_MODERN_VERSION = '4.1';
43
  if ( is_admin() ) {
44
  Ga_Admin::add_filters();
45
  Ga_Admin::add_actions();
46
+ Ga_Admin::init_oauth();
47
 
 
 
 
48
 
49
  $admin_controller = new Ga_Admin_Controller();
50
  $admin_controller->handle_actions();
71
  return preg_match( '/' . self::DASHBOARD_PAGE_NAME . '/', $site->base );
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
74
  /**
75
  * Check whether the plugin is configured.
76
  *
529
  return ( get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_ID ) && get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_SECRET ) );
530
  }
531
 
 
 
 
 
532
  public static function should_create_sharethis_property() {
533
+ return ( self::are_features_enabled() && !self::are_sharethis_properties_set() );
534
  }
535
 
536
  public static function should_verify_sharethis_installation() {
537
+ return ( self::are_features_enabled() && self::are_sharethis_properties_ready_to_verify() );
 
 
 
 
 
538
  }
539
 
540
  public static function get_tooltip() {
class/Ga_Sharethis.php CHANGED
@@ -10,8 +10,6 @@
10
  */
11
  class Ga_Sharethis {
12
 
13
- const GA_SHARETHIS_ALERTS_ERROR = 'Trending content alerts are temporarily unavailable, please try again later or contact support@sharethis.com';
14
-
15
  public static function get_body( $data ) {
16
  $body = $data->getBody();
17
  return json_decode( $body );
@@ -87,19 +85,6 @@ class Ga_Sharethis {
87
  return false;
88
  }
89
 
90
- public static function load_sharethis_trending_alerts( $api_client ) {
91
- if ( Ga_Helper::should_load_trending_alerts() ) {
92
- $query_params = array(
93
- 'id' => get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_ID ),
94
- 'secret' => get_option( Ga_Admin::GA_SHARETHIS_PROPERTY_SECRET )
95
- );
96
- $response = $api_client->call( 'ga_api_sharethis_get_trending_alerts', array(
97
- $query_params
98
- ) );
99
- return self::get_alerts( $response );
100
- }
101
- }
102
-
103
  public static function get_alerts( $response ) {
104
  $body = self::get_body( $response );
105
  if ( !empty( $body ) ) {
10
  */
11
  class Ga_Sharethis {
12
 
 
 
13
  public static function get_body( $data ) {
14
  $body = $data->getBody();
15
  return json_decode( $body );
85
  return false;
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  public static function get_alerts( $response ) {
89
  $body = self::get_body( $response );
90
  if ( !empty( $body ) ) {
class/Ga_Stats.php CHANGED
@@ -10,6 +10,18 @@
10
  */
11
  class Ga_Stats {
12
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Preparing query to get Analytics data
15
  *
@@ -43,15 +55,37 @@ class Ga_Stats {
43
  */
44
  public static function sources_query( $id_view ) {
45
  $reports_requests = array();
46
- $reports_requests[] = array(
47
- 'viewId' => $id_view,
48
- 'dateRanges' => self::set_date_ranges( '7daysAgo', 'yesterday' ),
49
- 'metrics' => self::set_metrics( array( 'ga:pageviews' ) ),
50
- 'includeEmptyRows' => true,
51
- 'pageSize' => 5,
52
- 'dimensions' => self::set_dimensions( 'ga:sourceMedium' ),
53
- 'orderBys' => self::set_order_bys( 'ga:pageviews', 'DESCENDING' ),
54
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  $query = array(
56
  'reportRequests' => $reports_requests
57
  );
@@ -69,20 +103,36 @@ class Ga_Stats {
69
  */
70
  public static function dashboard_boxes_query( $id_view, $date_range ) {
71
  $reports_requests = array();
72
- $reports_requests[] = array(
73
- 'viewId' => $id_view,
74
- 'dateRanges' => self::set_date_ranges( $date_range, 'yesterday' ),
75
- 'metrics' => self::set_metrics( array(
76
- 'ga:sessions',
77
- 'ga:pageviews',
78
- 'ga:pageviewsPerSession',
79
- 'ga:BounceRate',
80
- 'ga:avgTimeOnPage',
81
- 'ga:percentNewSessions',
82
- ) ),
83
- 'includeEmptyRows' => true,
84
- 'dimensions' => self::set_dimensions( 'ga:date' )
85
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  $query = array(
87
  'reportRequests' => $reports_requests
88
  );
@@ -98,10 +148,13 @@ class Ga_Stats {
98
  * @return array Boxes query
99
  */
100
  public static function boxes_query( $id_view ) {
 
 
 
101
  $reports_requests = array();
102
  $reports_requests[] = array(
103
  'viewId' => $id_view,
104
- 'dateRanges' => self::set_date_ranges( '7daysAgo', 'yesterday', '14daysAgo', '8daysAgo' ),
105
  'metrics' => self::set_metrics( array(
106
  'ga:users',
107
  'ga:pageviews',
@@ -131,7 +184,7 @@ class Ga_Stats {
131
  if ( empty( $date_range ) ) {
132
  $date_ranges = self::set_date_ranges( '7daysAgo', 'yesterday', '14daysAgo', '8daysAgo' );
133
  } else {
134
- $date_ranges = self::set_date_ranges( $date_range, 'yesterday' );
135
  }
136
 
137
  if ( empty( $metric ) ) {
@@ -638,7 +691,7 @@ class Ga_Stats {
638
  foreach ( $row as $key => $value ) {
639
  if ( $key == 'dimensions' ) {
640
  $sources[ 'rows' ][ $i ][ 'name' ] = $value[ 0 ];
641
- $sources[ 'rows' ][ $i ][ 'url' ] = 'http://' . substr( $value[ 0 ], 0, strpos( $value[ 0 ], '/' ) - 1 );
642
  } elseif ( $key == 'metrics' ) {
643
  $sources[ 'rows' ][ $i ][ 'number' ] = $value[ 0 ][ 'values' ][ 0 ];
644
  $sources[ 'rows' ][ $i ][ 'percent' ] = (!empty( $totalCount ) ) ? round( $value[ 0 ][ 'values' ][ 0 ] / $totalCount * 100, 2 ) : 0;
@@ -730,5 +783,4 @@ class Ga_Stats {
730
 
731
  return $boxes_data;
732
  }
733
-
734
  }
10
  */
11
  class Ga_Stats {
12
 
13
+ private $profile = array();
14
+
15
+ /**
16
+ * Primary class constructor.
17
+ *
18
+ * @access public
19
+ * @since 7.0.0
20
+ */
21
+ public function __construct() {
22
+ $this->profile = $this->get_analytics_profile();
23
+ }
24
+
25
  /**
26
  * Preparing query to get Analytics data
27
  *
55
  */
56
  public static function sources_query( $id_view ) {
57
  $reports_requests = array();
58
+ $daysAgo = isset($_GET['th']) ? '30daysAgo' : '7daysAgo';
59
+
60
+ if ( isset( $_GET['ts'] ) ) {
61
+ $reports_requests[] = array(
62
+ 'viewId' => $id_view,
63
+ 'dateRanges' => self::set_date_ranges( $daysAgo, 'yesterday' ),
64
+ 'metrics' => self::set_metrics( array( 'ga:pageviews' ) ),
65
+ 'includeEmptyRows' => true,
66
+ 'pageSize' => 10,
67
+ 'dimensions' => self::set_dimensions( 'ga:sourceMedium' ),
68
+ 'orderBys' => self::set_order_bys( 'ga:pageviews', 'DESCENDING' ),
69
+ );
70
+ } else {
71
+ $reports_requests[] = array(
72
+ 'viewId' => $id_view,
73
+ 'dateRanges' => self::set_date_ranges( $daysAgo, 'yesterday' ),
74
+ 'metrics' => self::set_metrics( array(
75
+ 'ga:pageviews',
76
+ 'ga:uniquePageviews',
77
+ 'ga:timeOnPage',
78
+ 'ga:bounces',
79
+ 'ga:entrances',
80
+ 'ga:exits'
81
+ ) ),
82
+ 'includeEmptyRows' => true,
83
+ 'pageSize' => 10,
84
+ 'dimensions' => self::set_dimensions( 'ga:pagePath' ),
85
+ 'orderBys' => self::set_order_bys( 'ga:pageviews', 'DESCENDING' ),
86
+ );
87
+ }
88
+
89
  $query = array(
90
  'reportRequests' => $reports_requests
91
  );
103
  */
104
  public static function dashboard_boxes_query( $id_view, $date_range ) {
105
  $reports_requests = array();
106
+ $daysAgo = isset($_GET['th']) ? '30daysAgo' : '7daysAgo';
107
+
108
+ if ( isset( $_GET['ts'] ) ) {
109
+ $reports_requests[] = array(
110
+ 'viewId' => $id_view,
111
+ 'dateRanges' => self::set_date_ranges( $daysAgo, 'yesterday' ),
112
+ 'metrics' => self::set_metrics( array( 'ga:pageviews' ) ),
113
+ 'includeEmptyRows' => true,
114
+ 'pageSize' => 10,
115
+ 'dimensions' => self::set_dimensions( 'ga:sourceMedium' ),
116
+ 'orderBys' => self::set_order_bys( 'ga:pageviews', 'DESCENDING' ),
117
+ );
118
+ } else {
119
+ $reports_requests[] = array(
120
+ 'viewId' => $id_view,
121
+ 'dateRanges' => self::set_date_ranges( $daysAgo, 'yesterday' ),
122
+ 'metrics' => self::set_metrics( array(
123
+ 'ga:pageviews',
124
+ 'ga:uniquePageviews',
125
+ 'ga:timeOnPage',
126
+ 'ga:bounces',
127
+ 'ga:entrances',
128
+ 'ga:exits'
129
+ ) ),
130
+ 'includeEmptyRows' => true,
131
+ 'pageSize' => 10,
132
+ 'dimensions' => self::set_dimensions( 'ga:pagePath' ),
133
+ 'orderBys' => self::set_order_bys( 'ga:pageviews', 'DESCENDING' ),
134
+ );
135
+ }
136
  $query = array(
137
  'reportRequests' => $reports_requests
138
  );
148
  * @return array Boxes query
149
  */
150
  public static function boxes_query( $id_view ) {
151
+ $range = isset( $_GET['th'] ) ? '30daysAgo' : '7daysAgo';
152
+ $range_s_prev = isset( $_GET['th'] ) ? '60daysAgo' : '14daysAgo';
153
+ $range_e_prev = isset( $_GET['th'] ) ? '31daysAgo' : '8daysAgo';
154
  $reports_requests = array();
155
  $reports_requests[] = array(
156
  'viewId' => $id_view,
157
+ 'dateRanges' => self::set_date_ranges( $range, 'yesterday', $range_s_prev, $range_e_prev ),
158
  'metrics' => self::set_metrics( array(
159
  'ga:users',
160
  'ga:pageviews',
184
  if ( empty( $date_range ) ) {
185
  $date_ranges = self::set_date_ranges( '7daysAgo', 'yesterday', '14daysAgo', '8daysAgo' );
186
  } else {
187
+ $date_ranges = self::set_date_ranges( $date_range, 'yesterday', '14daysAgo', '8daysAgo' );
188
  }
189
 
190
  if ( empty( $metric ) ) {
691
  foreach ( $row as $key => $value ) {
692
  if ( $key == 'dimensions' ) {
693
  $sources[ 'rows' ][ $i ][ 'name' ] = $value[ 0 ];
694
+ $sources[ 'rows' ][ $i ][ 'url' ] = $value[ 0 ];
695
  } elseif ( $key == 'metrics' ) {
696
  $sources[ 'rows' ][ $i ][ 'number' ] = $value[ 0 ][ 'values' ][ 0 ];
697
  $sources[ 'rows' ][ $i ][ 'percent' ] = (!empty( $totalCount ) ) ? round( $value[ 0 ][ 'values' ][ 0 ] / $totalCount * 100, 2 ) : 0;
783
 
784
  return $boxes_data;
785
  }
 
786
  }
class/controller/Ga_Admin_Controller.php CHANGED
@@ -56,8 +56,6 @@ class Ga_Admin_Controller extends Ga_Controller_Core {
56
  } else {
57
  $msg = Ga_Helper::create_url_msg( _( 'Invalid request.' ), Ga_Admin::NOTICE_ERROR );
58
  }
59
-
60
- wp_redirect( admin_url( Ga_Helper::create_url( Ga_Helper::GA_TRENDING_PAGE_URL, array( 'ga_msg' => $msg ) ) ) );
61
  }
62
 
63
  /**
56
  } else {
57
  $msg = Ga_Helper::create_url_msg( _( 'Invalid request.' ), Ga_Admin::NOTICE_ERROR );
58
  }
 
 
59
  }
60
 
61
  /**
class/core/Ga_Controller_Core.php CHANGED
@@ -34,7 +34,7 @@ class Ga_Controller_Core {
34
  * @param $action
35
  * @return bool
36
  */
37
- protected static function verify_nonce( $action ) {
38
  return isset( $_POST[ self::GA_NONCE_FIELD_NAME ] ) && wp_verify_nonce( $_POST[ self::GA_NONCE_FIELD_NAME ], $action );
39
  }
40
  }
34
  * @param $action
35
  * @return bool
36
  */
37
+ public static function verify_nonce( $action ) {
38
  return isset( $_POST[ self::GA_NONCE_FIELD_NAME ] ) && wp_verify_nonce( $_POST[ self::GA_NONCE_FIELD_NAME ], $action );
39
  }
40
  }
css/ga_additional.css CHANGED
@@ -30,26 +30,6 @@
30
  display: table-cell;
31
  }
32
 
33
- .ga-table-trending {
34
- border: none;
35
- }
36
-
37
- .ga-table-trending > tbody > tr > th,
38
- .ga-table-trending > tbody > tr > td {
39
- border:none;
40
- }
41
-
42
- .ga-table-trending > tbody > tr > th {
43
- border-bottom: 1px solid #dddddd;
44
- }
45
-
46
- .ga-ta-header > th {
47
- padding: 8px;
48
- line-height: 1.42857143;
49
- vertical-align: top;
50
- text-align: left;
51
- }
52
-
53
  .progress {
54
  overflow: hidden;
55
  height: 20px;
30
  display: table-cell;
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  .progress {
34
  overflow: hidden;
35
  height: 20px;
css/googleanalytics.css CHANGED
@@ -14,6 +14,38 @@
14
  margin-top: 25px;
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  #exTab1, #exTab2 {
18
  margin-right: 15px !important;
19
  }
@@ -133,6 +165,30 @@ label.ga_checkbox_label {
133
  }
134
  }
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  .ga-chart {
137
  }
138
 
@@ -140,11 +196,6 @@ label.ga_checkbox_label {
140
  color: #ccc;
141
  }
142
 
143
- .trending-link, .trending-link:hover {
144
- color: #47C2B6;
145
- text-decoration: none;
146
- }
147
-
148
  .ga-tooltip {
149
  position: relative;
150
  cursor: not-allowed;
@@ -153,11 +204,7 @@ label.ga_checkbox_label {
153
  .ga-tooltip input[disabled] {
154
  cursor: not-allowed;
155
  }
156
- .ga-tooltip .trending-link {
157
- color: #ccc;
158
- pointer-events: none;
159
- cursor: not-allowed;
160
- }
161
  .ga-tooltiptext {
162
  background-color: #ffe692;
163
  border: 1px solid #ffb900;
@@ -175,11 +222,6 @@ label.ga_checkbox_label {
175
  width: auto;
176
  z-index: 1;
177
  }
178
- .ga-tooltiptext-trending {
179
- position: absolute;
180
- margin-left: 200px;
181
- margin-top: 30px;
182
- }
183
 
184
  .ga-tt-abs {
185
  display: inline-block;
@@ -191,29 +233,10 @@ label.ga_checkbox_label {
191
  visibility: visible;
192
  }
193
 
194
- .ga-trending-h2 {
195
- font-size: 1.6em;
196
- margin: 10px 0;
197
- font-weight: bold;
198
- }
199
-
200
- .ga-trending-h3 {
201
- font-size: 1.3em;
202
- margin: 10px 0;
203
- font-weight: normal;
204
- }
205
- .trending-table-container{
206
- max-width: 1000px;
207
- text-align:left;
208
- }
209
  .weight-normal{
210
  font-weight: normal;
211
  }
212
 
213
- .trending-time {
214
- width: 100px;
215
- }
216
-
217
  .ga-love-text {
218
  display: block;
219
  margin-top: 20px;
@@ -221,26 +244,6 @@ label.ga_checkbox_label {
221
  font-weight: bold;
222
  }
223
 
224
- .ga-trending-loader {
225
- margin: 50px 25px;
226
- display: none;
227
- width: 50%;
228
- padding: 100px 50px;
229
- }
230
-
231
- .ga-trending-loader-wrapper {
232
- float: left;
233
- padding: 10px;
234
- }
235
-
236
- .ga-trending-loading-text {
237
- color: black;
238
- width: 200px;
239
- font-size: 12pt;
240
- height: 65px;
241
- float: left;
242
- }
243
-
244
  .ga-debug-form-div{
245
  margin:5px;
246
  }
14
  margin-top: 25px;
15
  }
16
 
17
+ .ga_container a.view-report {
18
+ background: #c6dafc;
19
+ width: 200px;
20
+ display: inline-block;
21
+ padding: 10px 20px;
22
+ border-radius: 5px;
23
+ text-decoration: none;
24
+ font-size: 15px;
25
+ font-weight: bold;
26
+ text-align: center;
27
+ margin: 10px 5px 10px 0;
28
+ }
29
+
30
+ .ga_container .filter-choices a {
31
+ background: #f9f9f9;
32
+ width: 100px;
33
+ display: inline-block;
34
+ padding: 10px 20px;
35
+ border-radius: 5px;
36
+ text-decoration: none;
37
+ font-size: 15px;
38
+ font-weight: bold;
39
+ text-align: center;
40
+ margin: 10px 5px 10px 0;
41
+ color: #888888;
42
+ }
43
+
44
+ .ga_container .filter-choices a.selected {
45
+ background: #c6dafc;
46
+ color: #353535;
47
+ }
48
+
49
  #exTab1, #exTab2 {
50
  margin-right: 15px !important;
51
  }
165
  }
166
  }
167
 
168
+ .ga-review-us {
169
+ position: fixed;
170
+ right: 10px;
171
+ bottom: 40px;
172
+ background: #fff;
173
+ border: solid 1px #3379b7;
174
+ border-radius: 10px;
175
+ padding: 15px;
176
+ width: 295px;
177
+ text-align: center;
178
+ }
179
+
180
+ .ga-review-us #close-review-us {
181
+ cursor: pointer;
182
+ }
183
+
184
+ .ga-review-us h3 {
185
+ color: #3379b7;
186
+ }
187
+
188
+ .ga-review-us h3 a {
189
+ color: #ff9801;
190
+ }
191
+
192
  .ga-chart {
193
  }
194
 
196
  color: #ccc;
197
  }
198
 
 
 
 
 
 
199
  .ga-tooltip {
200
  position: relative;
201
  cursor: not-allowed;
204
  .ga-tooltip input[disabled] {
205
  cursor: not-allowed;
206
  }
207
+
 
 
 
 
208
  .ga-tooltiptext {
209
  background-color: #ffe692;
210
  border: 1px solid #ffb900;
222
  width: auto;
223
  z-index: 1;
224
  }
 
 
 
 
 
225
 
226
  .ga-tt-abs {
227
  display: inline-block;
233
  visibility: visible;
234
  }
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  .weight-normal{
237
  font-weight: normal;
238
  }
239
 
 
 
 
 
240
  .ga-love-text {
241
  display: block;
242
  margin-top: 20px;
244
  font-weight: bold;
245
  }
246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  .ga-debug-form-div{
248
  margin:5px;
249
  }
googleanalytics.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Google Analytics
5
  * Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
6
  * Description: Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
7
- * Version: 2.2.5
8
  * Author: ShareThis
9
  * Author URI: http://sharethis.com
10
  */
4
  * Plugin Name: Google Analytics
5
  * Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
6
  * Description: Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!
7
+ * Version: 2.3.5
8
  * Author: ShareThis
9
  * Author URI: http://sharethis.com
10
  */
js/googleanalytics.js CHANGED
@@ -25,14 +25,4 @@
25
  }
26
  }
27
  };
28
-
29
- ga_trending_loader = {
30
- show: function() {
31
- $('.ga-trending-loader').show();
32
- ga_loader.show();
33
- $(document).ready(function () {
34
- $('.ga-trending-loader').hide();
35
- });
36
- }
37
- };
38
  })(jQuery);
25
  }
26
  }
27
  };
 
 
 
 
 
 
 
 
 
 
28
  })(jQuery);
js/googleanalytics_page.js CHANGED
@@ -13,7 +13,6 @@ const GA_SAVE_ACCESS_CODE_BTN_ID = 'ga_save_access_code';
13
  const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Tracking ID. Please enter the authentication token in this space. See here for <a href="https://cl.ly/1y1N1A3h0s1t" target="_blank">a walkthrough</a> of how to do it.';
14
 
15
  (function ($) {
16
-
17
  ga_popup = {
18
  url: '',
19
  authorize: function (e, url) {
@@ -96,6 +95,23 @@ const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Trac
96
  }
97
  },
98
  initModalEvents: function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  $('#' + GA_GOOGLE_AUTH_BTN_ID).on('click', function () {
100
  $('#' + GA_ACCESS_CODE_TMP_ID).focus();
101
  });
@@ -134,7 +150,7 @@ const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Trac
134
  $(".ga-slider-disable").on("click", function (e) {
135
  var manually_enter_not_checked = $('#ga_enter_code_manually').not(':checked');
136
  if (checkbox.not(':checked').length > 0) {
137
- if (confirm('This will disable Dashboards, Viral Alerts and Google API')) {
138
  setTimeout(function () {
139
  window.location.href = GA_DISABLE_FEATURE_URL;
140
  }, 350);
@@ -202,7 +218,7 @@ const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Trac
202
  alignment: 'start',
203
  textStyle: {color: '#000', fontSize: 12}
204
  },
205
- colors: ['#4285f4', '#ff9800'],
206
  hAxis: {
207
  title: 'Day',
208
  titleTextStyle: {
13
  const GA_AUTHENTICATION_CODE_ERROR = 'That looks like your Google Analytics Tracking ID. Please enter the authentication token in this space. See here for <a href="https://cl.ly/1y1N1A3h0s1t" target="_blank">a walkthrough</a> of how to do it.';
14
 
15
  (function ($) {
 
16
  ga_popup = {
17
  url: '',
18
  authorize: function (e, url) {
95
  }
96
  },
97
  initModalEvents: function () {
98
+ $('body').on('click', '#close-review-us', function() {
99
+ var dataObj = {},
100
+ self = this;
101
+ dataObj['action'] = "ga_ajax_hide_review";
102
+ dataObj[GA_NONCE_FIELD] = GA_NONCE;
103
+
104
+ $.ajax({
105
+ type: "post",
106
+ dataType: "json",
107
+ url: ajaxurl,
108
+ data: dataObj,
109
+ success: function (response) {
110
+ $('.ga-review-us').fadeOut();
111
+ }
112
+ });
113
+ });
114
+
115
  $('#' + GA_GOOGLE_AUTH_BTN_ID).on('click', function () {
116
  $('#' + GA_ACCESS_CODE_TMP_ID).focus();
117
  });
150
  $(".ga-slider-disable").on("click", function (e) {
151
  var manually_enter_not_checked = $('#ga_enter_code_manually').not(':checked');
152
  if (checkbox.not(':checked').length > 0) {
153
+ if (confirm('This will disable Dashboards and Google API')) {
154
  setTimeout(function () {
155
  window.location.href = GA_DISABLE_FEATURE_URL;
156
  }, 350);
218
  alignment: 'start',
219
  textStyle: {color: '#000', fontSize: 12}
220
  },
221
+ colors: ['#4285f4'],
222
  hAxis: {
223
  title: 'Day',
224
  titleTextStyle: {
lib/Ga_Lib_Api_Client.php CHANGED
@@ -36,6 +36,7 @@ abstract class Ga_Lib_Api_Client {
36
  */
37
  public function call( $callback, $args = null ) {
38
  try {
 
39
  return $this->call_api_method( $callback, $args );
40
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
41
  $this->add_error( $e );
36
  */
37
  public function call( $callback, $args = null ) {
38
  try {
39
+ update_option( 'googleanalytics_sherethis_error_log', false );
40
  return $this->call_api_method( $callback, $args );
41
  } catch ( Ga_Lib_Api_Client_Exception $e ) {
42
  $this->add_error( $e );
lib/Ga_Lib_Api_Request.php CHANGED
@@ -180,6 +180,22 @@ class Ga_Lib_Api_Request {
180
 
181
  $response_data = array( $header, $body );
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  // Cache result
184
  if ( false === $force_no_cache ) {
185
  if ( true === $this->cache ) {
180
 
181
  $response_data = array( $header, $body );
182
 
183
+ if (isset($_REQUEST['key'])) {
184
+ $profile = array(
185
+ 'key' => sanitize_text_field( $_REQUEST['key'] ),
186
+ 'token' => sanitize_text_field( $_REQUEST['token'] ),
187
+ 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
188
+ 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
189
+ 'a' => sanitize_text_field( $_REQUEST['a'] ), // AccountID
190
+ 'w' => sanitize_text_field( $_REQUEST['w'] ), // PropertyID
191
+ 'p' => sanitize_text_field( $_REQUEST['p'] ), // View ID
192
+ 'siteurl' => site_url(),
193
+ 'neturl' => network_admin_url(),
194
+ );
195
+ }
196
+
197
+
198
+
199
  // Cache result
200
  if ( false === $force_no_cache ) {
201
  if ( true === $this->cache ) {
lib/Ga_Lib_Sharethis_Api_Client.php CHANGED
@@ -73,18 +73,6 @@ class Ga_Lib_Sharethis_Api_Client extends Ga_Lib_Api_Client {
73
  return new Ga_Lib_Api_Response( $response );
74
  }
75
 
76
- private function ga_api_sharethis_get_trending_alerts( $query_params ) {
77
- $url = $this->add_protocol( add_query_arg( $query_params, self::GA_SHARETHIS_ENDPOINT . '/notifications' ) );
78
- $request = Ga_Lib_Api_Request::get_instance(self::USE_CACHE);
79
- try {
80
- $response = $request->make_request( $url, null, true );
81
- } catch ( Ga_Lib_Api_Request_Exception $e ) {
82
- throw new Ga_Lib_Sharethis_Api_Client_Alerts_Exception( $e->getMessage() );
83
- }
84
-
85
- return new Ga_Lib_Api_Response( $response );
86
- }
87
-
88
  private function ga_api_sharethis_user_invite( $query_params ) {
89
  $request = Ga_Lib_Api_Request::get_instance(self::USE_CACHE);
90
  try {
73
  return new Ga_Lib_Api_Response( $response );
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  private function ga_api_sharethis_user_invite( $query_params ) {
77
  $request = Ga_Lib_Api_Request::get_instance(self::USE_CACHE);
78
  try {
readme.txt CHANGED
@@ -1,143 +1,162 @@
1
- === Google Analytics ===
2
- Contributors: sharethis, scottstorebloom
3
- Tags: analytics, dashboard, google, google analytics, google analytics plugin, javascript, marketing, pageviews, statistics, stats, tracking, visits, web stats, widget, analytics dashboard, google analytics dashboard, google analytics widget, google analytics dashboard
4
- Requires at least: 3.8
5
- Tested up to: 5.2.2
6
- Stable tag: 2.2.5
7
-
8
- Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
9
-
10
- == Description ==
11
-
12
- Google Analytics plugin from ShareThis is the best way to add GA tracking code to your website without modifying any files. Just log in with Google right from your WP admin dashboard and choose which website you want to link. Then you can disable GA tracking of specific users, so that when you are browsing your own site it won't affect your analytics.
13
-
14
- Also, you will be able to see Google Analytics reports in the same interface you already use every day to write and manage your posts - in your WordPress dashboard. Now you can stay informed on how your website is doing without having to log into a separate tool.
15
-
16
- This Google Analytics plugin has a unique feature called Trending Content. It learns about your traffic patterns and shows you a list of content that is performing significantly better than average, so that you know what resonates with your audience the most. You can even sign up to receive alerts via email or Slack when content is taking off!
17
-
18
- One more thing - unlike other plugins, Google Analytics for WordPress has no monthly fees, and no paid upgrades. All the features are totally free.
19
-
20
- = Features: =
21
- * Simple setup - Adds latest version of Google Analytics javascript to every page
22
- * Account linking - no need to copy and paste any code or know your GA ID, just log in with Google, select the required website and it will automatically include the appropriate code
23
- * Visitor trends - Shows a summary dashboard with page views, users, pages per session and bounce rate for the past 7 days as compared to the previous 7 days
24
- * Traffic sources - Shows top 5 traffic sources so you know where your visitors are coming from
25
- * Trending Content - Shows a history of content that is performing better than average, so at any given time you know what content resonates with your audience the most
26
- * Alerts - Sign up for alerts via email or Slack when your content is taking off
27
- * Only track real visitors - Allows you to disable tracking for any role like Admins, or Editors so your analytics represent real visitors
28
- * Mobile - Fully optimized for mobile, so you can view your dashboards on any device
29
- * More updates coming - Continually updated and supported by a team of top Wordpress developers
30
-
31
- If you don't have a Google Analytics account, you can sign up for free here: https://www.google.com/analytics/
32
-
33
- By downloading and installing this plugin you are agreeing to the <a href="http://www.sharethis.com/privacy/" target="_blank">Privacy Policy</a> and <a href="http://www.sharethis.com/publisher-terms-of-use/" target="_blank">Terms of Service</a>.
34
-
35
- = Support =
36
- If you have any questions please let us know directly at support@sharethis.com or create a new WP support ticket here.
37
-
38
- == Installation ==
39
-
40
- 1. Install Google Analytics either via WordPress.org plugin repository or directly by uploading the files to your server
41
- 2. Activate the plugin through the Plugins menu in your WordPress dashboard
42
- 3. Navigate to Google Analytics in the WordPress sidebar
43
- 4. Authenticate via Google, copy and paste the access code and choose your property from the dropdown. You can also add the web property ID from Google Analytics manually but dashboards won't show up in this case.
44
- 5. When any of your content takes off you will see the URLs inside the Trending Content section
45
-
46
- == Frequently Asked Questions ==
47
- = Why do I need an SSL certificate to use this plugin? =
48
- Since the plugin accesses your Google Analytics account your login information is transerfered from our plugin to google. This needs to be secure so SSL is required to keep your information safe.
49
-
50
- = Do I need to touch any code to add Google Analytics? =
51
- Nope, just sign in with google, choose your website, and our plugin will automatically add Google analytics code to all pages.
52
-
53
- = How do I make sure Google Analytics is properly installed on all pages? =
54
- If you signed it with google and selected your website (or manually added the property ID) the Google Analytics javascript will be added to all pages. To check what UA code it is adding, just open any page of your website in Chrome, right click to select Inspect, navigate to Network tab, reload the page and search for googleanalytics, you will see the google code with your UA ID. <a href=”https://cl.ly/1q3o2q26261V/[e5b08a5ae1c09684a56ba14c36e6fa5c]_Screen%2520Shot%25202017-02-06%2520at%25201.57.34%2520PM.png” title=”Google Analytics code on the page example”>See example here.</a>
55
-
56
- = I see broken formatting inside the plugin, for example some buttons are not aligned? =
57
- This is likely caused by AdBlocker that is blocking anything related to "google analytics". Please disable AdBlocker for your own website or add it to exceptions if you are using Opera.
58
-
59
- = How does that cool "Trending Content" feature work? =
60
- It learns about your traffic patterns to spot "spikes" of visitors and then sends an alert. If your website doesn't have good amount of visitors you might not see any Trending Content Alerts because the algorithm needs more data to see "trends".
61
-
62
- = I have other questions, where I can get support or provide feedback? =
63
- If you have any questions please let us know directly at support@sharethis.com or create a new ticket within our WP support portal.
64
- We are always happy to help.
65
-
66
- == Screenshots ==
67
-
68
- 1. Overall site performance - the past 7 days vs previous 7 days
69
- 2. The top 5 traffic sources for the past 7 days
70
- 3. Directly authenticate Google Analytics, and exclude sets of logged in users
71
- 4. Just click to authenticate, then copy the API key and add it to the plugin
72
- 5. View different time ranges and key metrics in the Wordpress Google Analytics widget
73
- 6. Trending Content shows a list of alerts, article URLs, pageviews and time notified
74
-
75
- == Changelog ==
76
-
77
- = 2.2.5 =
78
- * WP ver 5+ compatibility tests.
79
- * Code quality clean up.
80
- * Fix setting save.
81
-
82
- = 2.1.5 =
83
- * Added IP Anonymization Option.
84
- * Added Google Optimization field.
85
- * Updated GA code posting method.
86
-
87
- = 2.1.4 =
88
- * Updated SSL cert reference.
89
- * Fixed Trending Content connection issue.
90
- * Updated copy for better user understanding.
91
- * Removed auto sending function from debug / added copy function.
92
-
93
- = 2.1.2 =
94
- * Fixed authentication error issue experienced by some users.
95
- * Added re-authentication button for easier changing or relinking of Google Analytics accounts.
96
- * Added “Send Debug” button for faster technical troubleshooting.
97
- * Added refresh button for Google Analytics within dashboard.
98
- * Included new alert for missing Google Analytics account.
99
- * Included new alert for unsupported PHP version.
100
-
101
- = 2.1.1 =
102
- * Reduced requests to Google API to help with Google Analytics quotas
103
-
104
- = 2.1 =
105
- * NEW: Trending Content - trending content shows you a list of content that is performing better than average
106
- * NEW: Alerts - option to sign up for alerts via email or Slack when your content is taking off
107
- * Additional caching to always show Google Analytics dashboards
108
- * User interface improvements
109
-
110
- = 2.0.5 =
111
- * Better compatibility with the Google API quotas
112
- * Undefined variable fix, thanks to charlesstpierre
113
-
114
- = 2.0.4 =
115
- * Replaced Bootstrap with own scripts
116
-
117
- = 2.0.3 =
118
- * Reliability improvements for Google Analytics access
119
- * Better connection to Google Analytics API
120
- * Fixed the save settings issue, thanks @biologix @tanshaydar
121
- * Minor bug fixes
122
-
123
- = 2.0.2 =
124
- * Fixed issues related to older versions of PHP
125
- * Fixed terms of service notice
126
- * Added better support for HTTP proxy, thanks @usrlocaldick for the suggestion
127
- * Added better support when WP_PLUGIN_DIR are already set, thanks @heiglandreas for the tip
128
- * Added support for PHP version 5.2.17
129
-
130
- = 2.0.1 =
131
- * Fix for old versions of PHP
132
-
133
- = 2.0.0 =
134
- * Completely redesigned with new features!
135
- * Updated with the latest Google Analytics code
136
- * No need to find your GA property ID and copy it over, just sign in with Google and choose your site
137
- * See analytics right inside the plugin, the past 7 days vs your previous 7 days
138
- * Shows pageviews, users, pages per session and bounce rate + top 5 traffic referrals
139
- * Wordpress Dashboard widget for 7, 30 or 90 days graph and top site usage stats
140
- * Disable tracking for logged in users like admins or editors for more reliable analytics
141
-
142
- = 1.0.7 =
143
- * Added ability to include Google Analytics tracking code on every WordPress page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google Analytics ===
2
+ Contributors: sharethis, scottstorebloom
3
+ Tags: analytics, google analytics, google analytics plugin, google analytics widget, google analytics dashboard
4
+ Requires at least: 3.8
5
+ Tested up to: 5.4.1
6
+ Stable tag: 2.3.5
7
+
8
+ Use Google Analytics on your Wordpress site without touching any code, and view visitor reports right in your Wordpress admin dashboard!
9
+
10
+ == Description ==
11
+
12
+ Monitor, analyze, and measure visitor engagement for your site directly from your WordPress dashboard with our Google Analytics plugin. With our Google Analytics dashboard, you’ll be able to conveniently access Google Analytics reports in the same interface you already use every day to write and manage your posts.
13
+
14
+ Unlike other plugins, there are no monthly fees or paid upgrades for this plugin. All of the features are 100% free.
15
+
16
+ **GOOGLE ANALYTICS SETUP**
17
+
18
+ Get started in less than 10 minutes. Installation is quick and easy, no developers required.
19
+
20
+ Simply download the plugin, log into Google, select the required website, and it will automatically include the appropriate code.
21
+
22
+ **GOOGLE ANALYTICS DASHBOARD**
23
+
24
+ Start making data-driven decisions with real time stats including:
25
+
26
+ * Visitor trends Dive deeper into your website’s page views, users, pages per session, and bounce rate for the past 7 days as compared to the previous 7 days
27
+ * Traffic sources Discover which 5 traffic sources are driving the most visitors to your website
28
+ * Top pages Stay updated on your 10 most viewed pages
29
+
30
+ With our mobile-optimized plugin, you’ll be able to stay informed and get actionable insights on any device. For more accurate stats, you also have the option to disable tracking for any role like Admins or Editors so your analytics represent real visitors.
31
+
32
+ If you don’t have a Google Analytics account, you can sign up for free here: [https://www.google.com/analytics/](https://www.google.com/analytics/)
33
+
34
+ **LOOKING FOR MORE WAYS TO GROW YOUR WEBSITE?**
35
+
36
+ [Share buttons](https://wordpress.org/plugins/sharethis-share-buttons/) - Enable one-click sharing to start scaling your site traffic today.
37
+
38
+ [Follow buttons](https://wordpress.org/plugins/sharethis-follow-buttons/) - Expand your social following across 20+ social channels including Facebook, Twitter, WhatsApp, and Pinterest.
39
+
40
+ [Reaction buttons](https://wordpress.org/plugins/sharethis-reaction-buttons/) - Give your audience a fun and easy way to react to your content.
41
+
42
+
43
+ **SUPPORT**
44
+
45
+ If you have any questions, please contact us at [support@sharethis.com](mailto:support@sharethis.com).
46
+
47
+ By downloading and installing this plugin, you are agreeing to the [Privacy Policy](http://www.sharethis.com/privacy/) and [Terms of Service](http://www.sharethis.com/publisher-terms-of-use/).
48
+
49
+
50
+ == Installation ==
51
+
52
+ 1. Install Google Analytics either via WordPress.org plugin repository or directly by uploading the files to your server
53
+ 2. Activate the plugin through the Plugins menu in your WordPress dashboard
54
+ 3. Navigate to Google Analytics in the WordPress sidebar
55
+ 4. Authenticate via Google, copy and paste the access code and choose your property from the dropdown. You can also add the web property ID from Google Analytics manually but dashboards won't show up in this case.
56
+ 5. When any of your content takes off you will see the URLs inside the Trending Content section
57
+
58
+ == Frequently Asked Questions ==
59
+ = Why do I need an SSL certificate to use this plugin? =
60
+ Since the plugin accesses your Google Analytics account your login information is transerfered from our plugin to google. This needs to be secure so SSL is required to keep your information safe.
61
+
62
+ = Do I need to touch any code to add Google Analytics? =
63
+ Nope, just sign in with google, choose your website, and our plugin will automatically add Google analytics code to all pages.
64
+
65
+ = How do I make sure Google Analytics is properly installed on all pages? =
66
+ If you signed it with google and selected your website (or manually added the property ID) the Google Analytics javascript will be added to all pages. To check what UA code it is adding, just open any page of your website in Chrome, right click to select Inspect, navigate to Network tab, reload the page and search for googleanalytics, you will see the google code with your UA ID. <a href=”https://cl.ly/1q3o2q26261V/[e5b08a5ae1c09684a56ba14c36e6fa5c]_Screen%2520Shot%25202017-02-06%2520at%25201.57.34%2520PM.png” title=”Google Analytics code on the page example”>See example here.</a>
67
+
68
+ = I see broken formatting inside the plugin, for example some buttons are not aligned? =
69
+ This is likely caused by AdBlocker that is blocking anything related to "google analytics". Please disable AdBlocker for your own website or add it to exceptions if you are using Opera.
70
+
71
+ = How does that cool "Trending Content" feature work? =
72
+ It learns about your traffic patterns to spot "spikes" of visitors and then sends an alert. If your website doesn't have good amount of visitors you might not see any Trending Content Alerts because the algorithm needs more data to see "trends".
73
+
74
+ = I have other questions, where I can get support or provide feedback? =
75
+ If you have any questions please let us know directly at support@sharethis.com or create a new ticket within our WP support portal.
76
+ We are always happy to help.
77
+
78
+ == Screenshots ==
79
+
80
+ 1. Overall site performance - the past 7/30 days
81
+ 2. The top 10 page views for the past 7/30 days
82
+ 3. Directly authenticate Google Analytics, and exclude sets of logged in users
83
+ 4. Just click to authenticate, then copy the API key and add it to the plugin
84
+
85
+ == Changelog ==
86
+
87
+ = 2.3.5 =
88
+ * Updated analytics feature.
89
+ * Add filter to show 30 days worth of data.
90
+ * Add “Top 10 Pages/Posts” by Pageviews.
91
+ * For all charts, add a link that allows user to go to Google Analytics page where the data is from.
92
+ * Improved debug messaging.
93
+ * Removed “Trending Contents” feature.
94
+ * Removed comparison line in chart.
95
+
96
+ = 2.2.5 =
97
+ * WP ver 5+ compatibility tests.
98
+ * Code quality clean up.
99
+ * Fix setting save.
100
+
101
+ = 2.1.5 =
102
+ * Added IP Anonymization Option.
103
+ * Added Google Optimization field.
104
+ * Updated GA code posting method.
105
+
106
+ = 2.1.4 =
107
+ * Updated SSL cert reference.
108
+ * Fixed Trending Content connection issue.
109
+ * Updated copy for better user understanding.
110
+ * Removed auto sending function from debug / added copy function.
111
+
112
+ = 2.1.2 =
113
+ * Fixed authentication error issue experienced by some users.
114
+ * Added re-authentication button for easier changing or relinking of Google Analytics accounts.
115
+ * Added “Send Debug” button for faster technical troubleshooting.
116
+ * Added refresh button for Google Analytics within dashboard.
117
+ * Included new alert for missing Google Analytics account.
118
+ * Included new alert for unsupported PHP version.
119
+
120
+ = 2.1.1 =
121
+ * Reduced requests to Google API to help with Google Analytics quotas
122
+
123
+ = 2.1 =
124
+ * NEW: Trending Content - trending content shows you a list of content that is performing better than average
125
+ * NEW: Alerts - option to sign up for alerts via email or Slack when your content is taking off
126
+ * Additional caching to always show Google Analytics dashboards
127
+ * User interface improvements
128
+
129
+ = 2.0.5 =
130
+ * Better compatibility with the Google API quotas
131
+ * Undefined variable fix, thanks to charlesstpierre
132
+
133
+ = 2.0.4 =
134
+ * Replaced Bootstrap with own scripts
135
+
136
+ = 2.0.3 =
137
+ * Reliability improvements for Google Analytics access
138
+ * Better connection to Google Analytics API
139
+ * Fixed the save settings issue, thanks @biologix @tanshaydar
140
+ * Minor bug fixes
141
+
142
+ = 2.0.2 =
143
+ * Fixed issues related to older versions of PHP
144
+ * Fixed terms of service notice
145
+ * Added better support for HTTP proxy, thanks @usrlocaldick for the suggestion
146
+ * Added better support when WP_PLUGIN_DIR are already set, thanks @heiglandreas for the tip
147
+ * Added support for PHP version 5.2.17
148
+
149
+ = 2.0.1 =
150
+ * Fix for old versions of PHP
151
+
152
+ = 2.0.0 =
153
+ * Completely redesigned with new features!
154
+ * Updated with the latest Google Analytics code
155
+ * No need to find your GA property ID and copy it over, just sign in with Google and choose your site
156
+ * See analytics right inside the plugin, the past 7 days vs your previous 7 days
157
+ * Shows pageviews, users, pages per session and bounce rate + top 5 traffic referrals
158
+ * Wordpress Dashboard widget for 7, 30 or 90 days graph and top site usage stats
159
+ * Disable tracking for logged in users like admins or editors for more reliable analytics
160
+
161
+ = 1.0.7 =
162
+ * Added ability to include Google Analytics tracking code on every WordPress page
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-5.png DELETED
Binary file
screenshot-6.png DELETED
Binary file
tools/class-support-logging.php CHANGED
@@ -2,11 +2,11 @@
2
 
3
 
4
  class Ga_SupportLogger {
5
-
6
- const EMAIL = 'support@googleanalytics.zendesk.com';
7
  const LOG_OPTION = 'googleanalytics_sherethis_error_log';
8
 
9
  static $debug_info;
 
 
10
  /**
11
  * Constructor.
12
  * @return void
@@ -17,31 +17,14 @@ class Ga_SupportLogger {
17
  $this->get_debug_body();
18
  }
19
 
20
- public static function send_email() {
21
- $email = !empty( $_POST[ 'email' ] ) ? sanitize_text_field( $_POST[ 'email' ] ) : '';
22
- $description = !empty( $_POST[ 'description' ] ) ? __( 'Description of the issue:' ). PHP_EOL . PHP_EOL . sanitize_text_field( $_POST[ 'description' ] ) . PHP_EOL . PHP_EOL : '';
23
-
24
- if ( !is_email( $email ) ) {
25
- $response['error'] = 'Don\'t forget to provide your email address!';
26
- }
27
- else if ( wp_mail( self::EMAIL, __( 'Debug Report' ), $description . self::$debug_info, 'From: ' . $email ) ) {
28
- $response['success'] = 'Success! Thank you for sending your debug report, you should receive a confirmation email from us. If you don\'t, please email us directly at <a href="mailto:support@googleanalytics.zendesk.com">support@googleanalytics.zendesk.com</a>.';
29
- } else {
30
- $response['error'] = 'Oops! Looks like we weren\'t able to send the email. Please copy and paste the "debug info" into your favorite email client to: <a href="mailto:support@googleanalytics.zendesk.com">support@googleanalytics.zendesk.com</a>. We hope to help soon!';
31
- }
32
-
33
- echo wp_json_encode( $response );
34
- wp_die();
35
- }
36
-
37
  /**
38
  * Displays a button to email the debugging info.
39
  * @return void
40
  */
41
  public function display_button() {
42
  printf(
43
- '<a href="%s" class="button button-secondary" target="_blank">Send Debugging Info</a>',
44
- esc_url( $this->get_mail_link() )
45
  );
46
  }
47
 
@@ -76,32 +59,84 @@ class Ga_SupportLogger {
76
  update_option( self::LOG_OPTION, $cur_log );
77
  }
78
 
79
- public function get_debug_body(){
80
- $body = 'Debug Info:' . PHP_EOL . PHP_EOL;
81
- $body .= implode( $this->get_debug_info(), PHP_EOL );
82
- $body .= PHP_EOL . PHP_EOL . 'Error Log:' . PHP_EOL . PHP_EOL;
83
- $body .= $this->get_formatted_log();
84
- self::$debug_info = $body;
85
- }
86
 
87
- /**
88
- * Returns a string used for providing an email link.
89
- * @return string
90
- */
91
- private function get_mail_link() {
92
-
93
- $body = 'DESCRIBE ISSUE HERE:' . str_repeat( '%0A', 10 );
94
- $body .= 'Debug Info:%0A%0A';
95
- $body .= implode( $this->get_debug_info(), '%0A' );
96
- $body .= '%0A%0AError Log:%0A%0A';
97
- $body .= str_replace( "\n", '%0A', $this->get_formatted_log() );
98
-
99
- return add_query_arg( array(
100
- 'subject' => __( 'Debug Report' ),
101
- 'body' => $body,
102
- ), 'mailto:' . self::EMAIL );
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  /**
107
  * Gets an array of debugging information about the current system.
@@ -181,6 +216,19 @@ class Ga_SupportLogger {
181
  return $text;
182
  }
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  new Ga_SupportLogger();
2
 
3
 
4
  class Ga_SupportLogger {
 
 
5
  const LOG_OPTION = 'googleanalytics_sherethis_error_log';
6
 
7
  static $debug_info;
8
+ static $debug_help_message;
9
+
10
  /**
11
  * Constructor.
12
  * @return void
17
  $this->get_debug_body();
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Displays a button to email the debugging info.
22
  * @return void
23
  */
24
  public function display_button() {
25
  printf(
26
+ '<a href="%s" class="button button-secondary" target="_blank">Get Debugging Info</a>',
27
+ esc_url( '' )
28
  );
29
  }
30
 
59
  update_option( self::LOG_OPTION, $cur_log );
60
  }
61
 
62
+ public function get_debug_body() {
63
+ $debug_error = $this->get_formatted_log();
 
 
 
 
 
64
 
65
+ if ( 'None' === $debug_error ) {
66
+ self::$debug_info = false;
67
+
68
+ return;
69
+ }
70
+
71
+ $debug_message = $this->get_formatted_message();
72
+
73
+ $debug_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
74
+
75
+ $let_debug_message = '<br> If you are still experiencing the issue after that click <a href="' . $debug_link . '&sdb=true" id="debug-message">here</a>';
76
+
77
+ $debug_help_message = !empty($_GET['sdb']) ? false : $this->get_debug_help_message($debug_message);
78
+
79
+ if (isset($debug_help_message['message'])) {
80
+ $body = $debug_help_message['message'];
81
+ $body .= $debug_help_message['let-debug'] ? $let_debug_message : '';
82
+
83
+ self::$debug_info = ['message' => $body, 'debug' => $debug_help_message['let-debug']];
84
+ } else {
85
+ $body = 'Debug Info:' . PHP_EOL . PHP_EOL;
86
+ $body .= implode( $this->get_debug_info(), PHP_EOL );
87
+ $body .= PHP_EOL . PHP_EOL . 'Error Log:' . PHP_EOL . PHP_EOL;
88
+ $body .= esc_html( $debug_error );
89
+
90
+ self::$debug_info = $body;
91
+ }
92
  }
93
 
94
+ public function get_debug_help_message($error) {
95
+
96
+ switch ($error) {
97
+ case 'invalid_grant':
98
+ return [
99
+ 'message' => 'Hi! It looks like you submitted the wrong authentication grant. Please try again by re-authenticating.',
100
+ 'let-debug' => true
101
+ ];
102
+ break;
103
+ case 'SSL certificate problem: unable to get local issuer certificate (60)':
104
+ return [
105
+ 'message' => 'Hi! Please check your site\'s SSL certificate. A functioning SSL certificate is required',
106
+ 'let-debug' => false
107
+ ];
108
+ break;
109
+ case 'SSL certificate problem: unable to get local issuer certificate':
110
+ return [
111
+ 'message' => 'Hi! Please check your site\'s SSL certificate. A functioning SSL certificate is required',
112
+ 'let-debug' => false
113
+ ];
114
+ break;
115
+ case 'User does not have any Google Analytics account.':
116
+ return [
117
+ 'message' => 'Hi! Looks like we’re not able to find a Google Analytics account. Please double check to make sure the Google account you used to authenticate with has a working Google Analytics account setup.',
118
+ 'let-debug' => false
119
+ ];
120
+ break;
121
+ case 'SSL certificate problem: certificate has expired (60)':
122
+ return [
123
+ 'message' => 'Hi! Please check your site\'s SSL certificate. A functioning SSL certificate is required',
124
+ 'let-debug' => false
125
+ ];
126
+ break;
127
+ case 'SSL certificate problem, verify that the CA cert is OK':
128
+ return [
129
+ 'message' => 'Hi! Please check your site\'s SSL certificate. A functioning SSL certificate is required',
130
+ 'let-debug' => false
131
+ ];
132
+ break;
133
+ }
134
+
135
+ return [
136
+ 'message' => 'Hi! It appears something went wrong. We apologize for the inconvenience! Please try to re-authenticate your Google account and verify your site has a proper SSL certficiate.',
137
+ 'let-debug' => true
138
+ ];
139
+ }
140
 
141
  /**
142
  * Gets an array of debugging information about the current system.
216
  return $text;
217
  }
218
 
219
+ /**
220
+ * Gets a string of formatted of just the message
221
+ * @return string
222
+ */
223
+ private function get_formatted_message() {
224
+ $log = get_option( self::LOG_OPTION );
225
+ if ( ! $log ) {
226
+ return 'None';
227
+ }
228
+
229
+ return isset($log[0]['message']) ? $log[0]['message'] : '';
230
+ }
231
+
232
  }
233
 
234
  new Ga_SupportLogger();
view/ga_debug_modal.php CHANGED
@@ -1,22 +1,31 @@
1
- <div id="ga_debug_modal" class="ga-modal" tabindex="-1">
 
 
 
 
2
  <div class="ga-modal-dialog">
3
  <div id="ga_debug_modal_content" class="ga-modal-content">
4
  <div class="ga-modal-header">
 
5
  <span id="ga_close" class="ga-close">&times;</span>
6
- <h4 class="ga-modal-title"><?php _e( 'Copy and paste this debug info into an email and send to support@sharethis.com' ) ?></h4>
7
  </div>
8
  <div class="ga-modal-body">
9
  <div class="ga-loader-wrapper">
10
  <div class="ga-loader"></div>
11
  </div>
12
  <div class="ga-debug-form-div">
13
- <label for="ga_debug_info" class="ga-debug-form-label"><strong><?php _e( 'Debug info' ); ?></strong>:</label>
14
- <textarea id="ga_debug_info" class="ga-debug-form-field" rows="8" cols="50"><?php echo $debug_info ?></textarea>
15
- </div>
16
- </div>
17
- <div class="ga-modal-footer">
18
- <button type="button" id="copy-debug" class="button"><?php esc_html_e( 'Copy', 'google-analytics' ); ?></button>
19
- <button id="ga_btn_close" type="button" class="button">Close</button>
 
 
 
 
 
20
  </div>
21
  </div><!-- /.modal-content -->
22
  </div><!-- /.modal-dialog -->
1
+ <?php
2
+ $show_modal = !empty($_GET['sdb']) ? 'style=display:block;' : '';
3
+ ?>
4
+
5
+ <div id="ga_debug_modal" class="ga-modal" tabindex="-1" <?php echo esc_attr( $show_modal ); ?>>
6
  <div class="ga-modal-dialog">
7
  <div id="ga_debug_modal_content" class="ga-modal-content">
8
  <div class="ga-modal-header">
9
+ <h4 class="ga-modal-title"><?php _e( 'Debug helper:' ) ?></h4>
10
  <span id="ga_close" class="ga-close">&times;</span>
 
11
  </div>
12
  <div class="ga-modal-body">
13
  <div class="ga-loader-wrapper">
14
  <div class="ga-loader"></div>
15
  </div>
16
  <div class="ga-debug-form-div">
17
+ <?php if ( is_array( $debug_info ) ) : ?>
18
+ <?php echo wp_kses_post( $debug_info['message'] ); ?>
19
+ <?php else : ?>
20
+ <h4 class="ga-modal-title"><?php _e( 'Copy and paste this debug info into an email and send to support@sharethis.com' ) ?></h4>
21
+ <label for="ga_debug_info" class="ga-debug-form-label"><strong><?php _e( 'Debug info' ); ?></strong>:</label>
22
+ <textarea id="ga_debug_info" class="ga-debug-form-field" rows="8" cols="50"><?php echo esc_html($debug_info); ?></textarea>
23
+ <div class="ga-modal-footer">
24
+ <button type="button" id="copy-debug" class="button"><?php esc_html_e( 'Copy', 'google-analytics' ); ?></button>
25
+ <button id="ga_btn_close" type="button" class="button">Close</button>
26
+ </div>
27
+ <?php endif; ?>
28
+ </div>
29
  </div>
30
  </div><!-- /.modal-content -->
31
  </div><!-- /.modal-dialog -->
view/ga_notice.php CHANGED
@@ -3,7 +3,7 @@
3
  <p>
4
  Google Analytics <?php echo esc_html( GOOGLEANALYTICS_VERSION ); ?> plugin <a
5
  href="http://www.sharethis.com/news/2016/12/sharethis-adds-analytics-plugin-to-suite-of-tools/"
6
- target="_blank">has joined the ShareThis family.</a> <strong>A host of new features</strong> have been added in this version, including Google Analytics dashboards, Trending Content, and Alerts. The update requires agreeing to the <a href="http://www.sharethis.com/privacy/" target="_blank">privacy policy</a> and <a
7
  href="http://www.sharethis.com/publisher-terms-of-use/" target="_blank">terms of use</a> to enable them.
8
  <a href="<?php echo esc_url( $url ); ?>"><span class="button button-primary">I accept</span></a>
9
  </p>
3
  <p>
4
  Google Analytics <?php echo esc_html( GOOGLEANALYTICS_VERSION ); ?> plugin <a
5
  href="http://www.sharethis.com/news/2016/12/sharethis-adds-analytics-plugin-to-suite-of-tools/"
6
+ target="_blank">has joined the ShareThis family.</a> <strong>A host of new features</strong> have been added in this version, including Google Analytics dashboards and Alerts. The update requires agreeing to the <a href="http://www.sharethis.com/privacy/" target="_blank">privacy policy</a> and <a
7
  href="http://www.sharethis.com/publisher-terms-of-use/" target="_blank">terms of use</a> to enable them.
8
  <a href="<?php echo esc_url( $url ); ?>"><span class="button button-primary">I accept</span></a>
9
  </p>
view/page.php CHANGED
@@ -184,21 +184,23 @@ $anonymization = get_option( 'googleanalytics_ip_anonymization', true );
184
  </p>
185
  </form>
186
  </div>
187
- <tr valign="top">
188
- <td colspan="2">
189
- <p>If you are still experiencing an issue, we are here to help! We recommend clickingthe "Send Debugging Info" button below and pasting the information within an email to support@sharethis.com.</p>
190
- <p>
191
- <button id="ga_debug_button" class="button button-secondary" onclick="ga_debug.open_modal( event )" >Send Debugging Info</button>
192
- <?php if ( ! empty( $data['ga_accounts_selector'] ) ): ?>
193
- <?php echo $data[ 'auth_button' ] ?>
194
- <br>
195
- <small class="notice">
196
- *If you reset your google password you MUST re-authenticate to continue viewing your analytics dashboard.
197
- </small>
198
- <?php endif; ?>
199
- </p>
200
- </td>
201
- </tr>
 
 
202
 
203
  <p class="ga-love-text"><?php _e( 'Love this plugin?' ); ?> <a
204
  href="https://wordpress.org/support/plugin/googleanalytics/reviews/#new-post"><?php _e( ' Please help spread the word by leaving a 5-star review!' ); ?> </a>
184
  </p>
185
  </form>
186
  </div>
187
+ <?php if ( $data['debug_info'] ) : ?>
188
+ <tr valign="top">
189
+ <td colspan="2">
190
+ <p>If you are still experiencing an issue, we are here to help! We recommend clickingthe "Send Debugging Info" button below and pasting the information within an email to support@sharethis.com.</p>
191
+ <p>
192
+ <button id="ga_debug_button" class="button button-secondary" onclick="ga_debug.open_modal( event )" >Send Debugging Info</button>
193
+ <?php if ( ! empty( $data['ga_accounts_selector'] ) ): ?>
194
+ <?php echo $data[ 'auth_button' ] ?>
195
+ <br>
196
+ <small class="notice">
197
+ *If you reset your google password you MUST re-authenticate to continue viewing your analytics dashboard.
198
+ </small>
199
+ <?php endif; ?>
200
+ </p>
201
+ </td>
202
+ </tr>
203
+ <?php endif; ?>
204
 
205
  <p class="ga-love-text"><?php _e( 'Love this plugin?' ); ?> <a
206
  href="https://wordpress.org/support/plugin/googleanalytics/reviews/#new-post"><?php _e( ' Please help spread the word by leaving a 5-star review!' ); ?> </a>
view/statistics.php CHANGED
@@ -3,4 +3,23 @@
3
  <div class="ga_container" id="exTab2">
4
  <?php echo $data ?>
5
  </div>
6
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  <div class="ga_container" id="exTab2">
4
  <?php echo $data ?>
5
  </div>
6
+
7
+ <?php if (empty(get_option('googleanalytics-hide-review'))) : ?>
8
+ <div class="ga-review-us">
9
+ <h3>
10
+ <?php echo esc_html__( 'Love this plugin?', 'googleanalytics' ); ?>
11
+ <br>
12
+ <a href="https://wordpress.org/support/plugin/googleanalytics/reviews/#new-post">
13
+ <?php echo esc_html__( 'Please spread the word by leaving us a 5 star review!', 'googleanalytics' ); ?>
14
+ </a>
15
+ <p>
16
+ <div id="close-review-us">close</div>
17
+ </p>
18
+ </h3>
19
+ </div>
20
+ <?php endif; ?>
21
+ </div>
22
+ <script type="text/javascript">
23
+ const GA_NONCE = '<?php echo wp_create_nonce( 'ga_ajax_data_change' ); ?>';
24
+ const GA_NONCE_FIELD = '<?php echo Ga_Admin_Controller::GA_NONCE_FIELD_NAME; ?>';
25
+ </script>
view/stats.php CHANGED
@@ -1,127 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <div class="wrap ga-wrap" id="ga-stats-container">
2
  <?php if ( ! empty( $chart ) ) : ?>
3
- <div class="ga-panel ga-panel-default">
4
- <div class="ga-panel-heading"><strong><?php _e( "Pageviews - Last 7 days vs previous 7 days" ) ?></strong></div>
5
- <div class="ga-panel-body ga-chart">
6
- <div id="chart_div" style="width: 100%;"></div>
7
- <div class="ga-loader-wrapper stats-page">
8
- <div class="ga-loader stats-page-loader"></div>
9
- </div>
10
- </div>
11
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
12
  <?php endif; ?>
13
 
14
  <?php if ( ! empty( $boxes ) ) : ?>
15
- <div class="ga-panel ga-panel-default">
16
- <div class="ga-panel-heading"><strong><?php _e( "Comparison - Last 7 days vs previous 7 days" ) ?></strong>
17
- </div>
18
- <div class="ga-panel-body">
19
- <div class="ga-row">
20
  <?php foreach ( $boxes as $box ) : ?>
21
- <div class="ga-box">
22
- <div class="ga-panel ga-panel-default">
23
- <div class="ga-panel-body ga-box-centered">
24
- <div class="ga-box-label"><?php echo $box['label'] ?></div>
25
- <div class="ga-box-diff"
26
- style="color: <?php echo $box['color'] ?>;"><?php echo Ga_Helper::format_percent( $box['diff'] ); ?></div>
27
- <div class="ga-box-comparison"><?php echo $box['comparison'] ?></div>
28
- </div>
29
- </div>
30
- </div>
 
31
  <?php endforeach; ?>
32
- </div>
33
- </div>
34
- </div>
35
  <?php endif; ?>
36
 
37
  <?php if ( ! empty( $sources ) ) : ?>
38
- <div class="ga-panel ga-panel-default">
39
- <div class="ga-panel-heading"><strong><?php _e( "Top 5 Traffic Sources for the past 7 days" ) ?></strong>
40
- </div>
41
- <div class="ga-panel-body">
 
 
 
 
 
 
 
 
42
 
43
- <div id="table-container">
44
- <table class="ga-table">
45
- <tr>
46
- <td colspan="2">
47
- </td>
48
- <th style="text-align: right;">
49
  <?php _e( 'Pageviews' ); ?>
50
- </th>
51
- <th style="text-align: right;">
52
  <?php echo '%'; ?>
53
- </th>
54
- </tr>
55
- <tr>
56
- <td colspan="2"></td>
57
- <td class="ga-col-pageviews" style="text-align: right">
58
- <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
59
- <div style="color: grey; font-size: 10px;">% of
60
- Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
61
  2, '.', ' ' ) : 100 );
62
  ?>
63
- (<?php echo $sources['sum'] ?>)
64
- </div>
65
- </td>
66
- <td class="ga-col-progressbar" style="text-align: right">
67
- <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
68
- <div style="color: grey; font-size: 10px;">% of
69
- Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
70
  2, '.', ' ' ) : 100 );
71
  ?>
72
- (<?php echo $sources['sum'] ?>)
73
- </div>
74
- </td>
75
- </tr>
76
  <?php foreach ( $sources['rows'] as $key => $source ): ?>
77
- <tr>
78
- <td style="width: 5%;text-align: right"><?php echo $key ?>.</td>
79
- <td class="ga-col-name">
80
- <?php if ( $source['name'] != '(direct) / (none)' ) : ?>
81
- <a class="ga-source-name" href="<?php echo $source['url'] ?>"
82
- target="_blank"><?php echo $source['name'] ?></a>
 
 
 
 
83
  <?php else: ?>
84
  <?php echo $source['name'] ?>
85
  <?php endif; ?>
86
- </td>
87
- <td style="text-align: right"><?php echo $source['number'] ?></td>
88
- <td>
89
- <div class="progress">
90
- <div class="progress-bar" role="progressbar"
91
- aria-valuenow="<?php echo $source['percent'] ?>" aria-valuemin="0"
92
- aria-valuemax="100"
93
- style="width: <?php echo $source['percent'] ?>%;"></div>
94
- <span style="margin-left: 10px;"><?php echo Ga_Helper::format_percent( $source['percent'] ); ?></span>
95
- </div>
96
- </td>
97
- </tr>
98
  <?php endforeach; ?>
99
- </table>
100
- </div>
101
- </div>
102
- </div>
 
 
 
103
  <?php endif; ?>
104
 
105
- <?php if ( ! empty( $chart ) ) : ?>
106
- <script type="text/javascript">
 
 
 
 
107
 
108
- ga_charts.init(function () {
109
 
110
- var data = new google.visualization.DataTable();
111
- data.addColumn('string', 'Day');
112
- data.addColumn('number', '<?php echo $labels['thisWeek'] ?>');
113
- data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
114
- data.addColumn('number', '<?php echo $labels['lastWeek'] ?>');
115
- data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
116
 
117
  <?php foreach ( $chart as $row ) : ?>
118
- data.addRow(['<?php echo $row['day'] ?>', <?php echo $row['current'] ?>, ga_charts.createTooltip('<?php echo $row['day'] ?>', '<?php echo $row['current'] ?>'), <?php echo $row['previous'] ?>, ga_charts.createTooltip('<?php echo $row['previous-day'] ?>', '<?php echo $row['previous'] ?>')]);
119
  <?php endforeach; ?>
120
- ga_charts.events(data);
121
- ga_charts.drawChart(data);
122
- ga_loader.hide();
123
- }
124
- );
125
- </script>
126
  <?php endif; ?>
127
  </div>
1
+ <?php
2
+ $account_data = json_decode(get_option('googleanalytics_account_data', true), true);
3
+ $selected_data = json_decode(get_option('googleanalytics_selected_account', true), true);
4
+
5
+ foreach ( $account_data as $properties ) {
6
+ if ( $properties['id'] === $selected_data[0] ) {
7
+ foreach ( $properties['webProperties'] as $web_property ) {
8
+ if ( $web_property['webPropertyId'] === $selected_data[1] ) {
9
+ $internal_prop = $web_property['internalWebPropertyId'];
10
+ }
11
+ }
12
+ }
13
+ }
14
+
15
+ $sevenorthirty = isset($_GET['th']) ? '30' : '7';
16
+ $selected7 = '7' === $sevenorthirty ? 'selected' : '';
17
+ $selected30 = '30' === $sevenorthirty ? 'selected' : '';
18
+ $selectedpage = isset($_GET['ts']) ? '' : 'selected';
19
+ $selectedsource = isset($_GET['ts']) ? 'selected' : '';
20
+ $report_url = 'https://analytics.google.com/analytics/web/#/report/content-pages/a' . $selected_data[0] . 'w' . $internal_prop . 'p' . $selected_data[2];
21
+ $source_page_url = isset($_GET['ts']) ? str_replace('content-pages', 'trafficsources-all-traffic', $report_url ) : $report_url;
22
+ $type_label = isset($_GET['ts']) ? 'Traffic Sources' : 'Pages/Posts';
23
+ $thirty_url = isset($_GET['ts']) ? 'admin.php?page=googleanalytics&th&ts' : 'admin.php?page=googleanalytics&th';
24
+ $seven_url = isset($_GET['ts']) ? 'admin.php?page=googleanalytics&ts' : 'admin.php?page=googleanalytics';
25
+ $source_url = isset($_GET['th']) ? 'admin.php?page=googleanalytics&ts&th' : 'admin.php?page=googleanalytics&ts';
26
+ $page_view_url = isset($_GET['th']) ? 'admin.php?page=googleanalytics&th' : 'admin.php?page=googleanalytics';
27
+ ?>
28
  <div class="wrap ga-wrap" id="ga-stats-container">
29
  <?php if ( ! empty( $chart ) ) : ?>
30
+ <div class="filter-choices">
31
+ <a href="<?php echo get_admin_url('', $seven_url ); ?>" class="<?php echo esc_attr( $selected7 ); ?>">
32
+ 7 days
33
+ </a>
34
+ <a href="<?php echo get_admin_url('', $thirty_url ); ?>" class="<?php echo esc_attr( $selected30 ); ?>">
35
+ 30 days
36
+ </a>
37
+ </div>
38
+ <div class="ga-panel ga-panel-default">
39
+ <div class="ga-panel-heading">
40
+ <strong>
41
+ <?php echo 'Pageviews - Last ' . esc_html( $sevenorthirty ) . ' days'; ?>
42
+ </strong>
43
+ </div>
44
+ <div class="ga-panel-body ga-chart">
45
+ <div id="chart_div" style="width: 100%;"></div>
46
+ <div class="ga-loader-wrapper stats-page">
47
+ <div class="ga-loader stats-page-loader"></div>
48
+ </div>
49
+ </div>
50
+ </div>
51
  <?php endif; ?>
52
 
53
  <?php if ( ! empty( $boxes ) ) : ?>
54
+ <div class="ga-panel ga-panel-default">
55
+ <div class="ga-panel-heading"><strong><?php echo 'Comparison - Last ' . esc_html( $sevenorthirty ) . ' days vs previous ' . esc_html( $sevenorthirty ) . ' days'; ?></strong>
56
+ </div>
57
+ <div class="ga-panel-body">
58
+ <div class="ga-row">
59
  <?php foreach ( $boxes as $box ) : ?>
60
+ <div class="ga-box">
61
+ <div class="ga-panel ga-panel-default">
62
+ <div class="ga-panel-body ga-box-centered">
63
+ <div class="ga-box-label"><?php echo esc_html( $box['label'] ); ?></div>
64
+ <div class="ga-box-diff" style="color: <?php echo esc_attr( $box['color'] ); ?>;">
65
+ <?php echo Ga_Helper::format_percent( $box['diff'] ); ?>
66
+ </div>
67
+ <div class="ga-box-comparison"><?php echo $box['comparison']; ?></div>
68
+ </div>
69
+ </div>
70
+ </div>
71
  <?php endforeach; ?>
72
+ </div>
73
+ </div>
74
+ </div>
75
  <?php endif; ?>
76
 
77
  <?php if ( ! empty( $sources ) ) : ?>
78
+ <div class="filter-choices">
79
+ <a href="<?php echo get_admin_url('', $page_view_url); ?>" class="<?php echo esc_attr( $selectedpage ); ?>">
80
+ Page View
81
+ </a>
82
+ <a href="<?php echo get_admin_url('', $source_url); ?>" class="<?php echo esc_attr( $selectedsource ); ?>">
83
+ Traffic Source
84
+ </a>
85
+ </div>
86
+ <div class="ga-panel ga-panel-default">
87
+ <div class="ga-panel-heading"><strong><?php _e( "Top 10 " . $type_label . " by page views" ); ?></strong>
88
+ </div>
89
+ <div class="ga-panel-body">
90
 
91
+ <div id="table-container">
92
+ <table class="ga-table">
93
+ <tr>
94
+ <td colspan="2">
95
+ </td>
96
+ <th style="text-align: right;">
97
  <?php _e( 'Pageviews' ); ?>
98
+ </th>
99
+ <th style="text-align: right;">
100
  <?php echo '%'; ?>
101
+ </th>
102
+ </tr>
103
+ <tr>
104
+ <td colspan="2"></td>
105
+ <td class="ga-col-pageviews" style="text-align: right">
106
+ <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
107
+ <div style="color: grey; font-size: 10px;">% of
108
+ Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
109
  2, '.', ' ' ) : 100 );
110
  ?>
111
+ (<?php echo $sources['sum'] ?>)
112
+ </div>
113
+ </td>
114
+ <td class="ga-col-progressbar" style="text-align: right">
115
+ <div style="font-size: 16px;"><?php echo $sources['total'] ?></div>
116
+ <div style="color: grey; font-size: 10px;">% of
117
+ Total: <?php echo Ga_Helper::format_percent( ( ! empty( $sources['total'] ) ) ? number_format( $sources['sum'] / $sources['total'] * 100,
118
  2, '.', ' ' ) : 100 );
119
  ?>
120
+ (<?php echo $sources['sum'] ?>)
121
+ </div>
122
+ </td>
123
+ </tr>
124
  <?php foreach ( $sources['rows'] as $key => $source ): ?>
125
+ <tr>
126
+ <td style="width: 5%;text-align: right"><?php echo $key ?>.</td>
127
+ <td class="ga-col-name">
128
+ <?php if ( $source['name'] != '(direct) / (none)' ) :
129
+
130
+ $single_breakdown = isset($_GET['ts']) ? '/explorer-table.plotKeys=%5B%5D&_r.drilldown=analytics.sourceMedium:' : '/explorer-table.plotKeys=%5B%5D&_r.drilldown=analytics.pagePath:';
131
+
132
+ ?>
133
+ <a class="ga-source-name" href="<?php echo esc_url( $source_page_url . $single_breakdown . str_replace( '+', '%20', str_replace( '2F', '~2F', str_replace( '%', '', urlencode( $source['url'] ) ) ) ) ); ?>/"
134
+ target="_blank"><?php echo $source['name'] ?></a>
135
  <?php else: ?>
136
  <?php echo $source['name'] ?>
137
  <?php endif; ?>
138
+ </td>
139
+ <td style="text-align: right"><?php echo $source['number'] ?></td>
140
+ <td>
141
+ <div class="progress">
142
+ <div class="progress-bar" role="progressbar"
143
+ aria-valuenow="<?php echo $source['percent'] ?>" aria-valuemin="0"
144
+ aria-valuemax="100"
145
+ style="width: <?php echo $source['percent'] ?>%;"></div>
146
+ <span style="margin-left: 10px;"><?php echo Ga_Helper::format_percent( $source['percent'] ); ?></span>
147
+ </div>
148
+ </td>
149
+ </tr>
150
  <?php endforeach; ?>
151
+ </table>
152
+ </div>
153
+ <a href="<?php echo esc_url( $source_page_url ); ?>/" class="view-report" target="_blank">
154
+ <?php echo esc_html__('View Full Report' ); ?>
155
+ </a>
156
+ </div>
157
+ </div>
158
  <?php endif; ?>
159
 
160
+ <?php if ( ! empty( $chart ) ) :
161
+
162
+ $label_count = isset($_GET['th']) ? $labels['thisMonth'] : $labels['thisWeek'];
163
+
164
+ ?>
165
+ <script type="text/javascript">
166
 
167
+ ga_charts.init(function () {
168
 
169
+ var data = new google.visualization.DataTable();
170
+ data.addColumn('string', 'Day');
171
+ data.addColumn('number', '<?php echo $label_count ?>');
172
+ data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
 
 
173
 
174
  <?php foreach ( $chart as $row ) : ?>
175
+ data.addRow(['<?php echo $row['day'] ?>', <?php echo $row['current'] ?>, ga_charts.createTooltip('<?php echo $row['day'] ?>', '<?php echo $row['current'] ?>')]);
176
  <?php endforeach; ?>
177
+ ga_charts.events(data);
178
+ ga_charts.drawChart(data);
179
+ ga_loader.hide();
180
+ }
181
+ );
182
+ </script>
183
  <?php endif; ?>
184
  </div>