Google Analytics for WordPress by MonsterInsights - Version 4.3.2

Version Description

  • Bugfix: Google Analytics crappy API output is different when you have a single GA account versus multiple. Annoying, but fixed now.
Download this release

Release Info

Developer joostdevalk
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 4.3.2
Comparing to
See all releases

Code changes from version 4.3.1 to 4.3.2

Files changed (3) hide show
  1. admin/class-admin.php +55 -40
  2. googleanalytics.php +2 -2
  3. readme.txt +5 -1
admin/class-admin.php CHANGED
@@ -317,54 +317,69 @@ class GA_Admin extends Yoast_GA_Plugin_Admin {
317
  if ( !empty( $options['uastring'] ) )
318
  $currentua = $options['uastring'];
319
 
320
- // Check whether the feed output is the new one, first set, or the old one, second set.
321
- if ( $arr['feed']['link_attr']['href'] == 'https://www.googleapis.com/analytics/v2.4/management/accounts/~all/webproperties/~all/profiles' ) {
322
- foreach ( $arr['feed']['entry'] as $site ) {
323
- if ( isset( $site['dxp:property']['1_attr']['value'] ) )
324
- $ua = trim( $site['dxp:property']['1_attr']['value'] );
325
- if ( isset( $site['dxp:property']['2_attr']['value'] ) )
326
- $title = trim( $site['dxp:property']['2_attr']['value'] );
327
- if ( !empty( $ua ) && !empty( $title ) )
328
- $ga_accounts[$ua] = $title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  }
330
- } else if ( $arr['feed']['link_attr']['href'] == 'https://www.google.com/analytics/feeds/accounts/default' ) {
331
- foreach ( $arr['feed']['entry'] as $site ) {
332
- if ( isset( $site['dxp:property']['3_attr']['value'] ) )
333
- $ua = trim( $site['dxp:property']['3_attr']['value'] );
334
- if ( isset( $site['dxp:property']['1_attr']['value'] ) )
335
- $title = trim( $site['dxp:property']['1_attr']['value'] );
336
- if ( !empty( $ua ) && !empty( $title ) )
337
- $ga_accounts[$ua] = $title;
338
- }
339
- }
340
- asort( $ga_accounts );
341
 
342
- $select = '<select class="chzn-select" name="uastring" data-placeholder="' . __( 'Please select the correct Analytics Account', 'gawp' ) . '" id="ga_account">';
343
- $select .= "\t<option></option>\n";
344
- foreach ( $ga_accounts as $ua => $title ) {
345
- $sel = selected( $ua, $currentua, false );
346
- $select .= "\t" . '<option ' . $sel . ' value="' . $ua . '">' . $title . ' - ' . $ua . '</option>' . "\n";
347
- }
348
- $select .= '</select>';
349
 
350
- $line = '<input type="hidden" name="ga_token" value="' . $token . '"/>';
351
- $line .= __( 'Please select the correct Analytics account to track:', 'gawp' ) . '<br/>';
352
- $line .= '<table class="form_table">';
353
- $line .= '<tr><th>' . __( 'Profile', 'gawp' ) . ':</th><td>' . $select . '</td></tr>';
354
- $line .= '</table>';
355
 
356
- $try = 1;
357
- if ( isset( $_GET['try'] ) )
358
- $try = $_GET['try'] + 1;
359
 
360
- if ( count( $ga_accounts ) == 0 && $try < 4 && isset( $_GET['token'] ) ) {
361
- $line .= '<script type="text/javascript">
362
  window.location="' . $this->plugin_options_url() . '&switchua=1&token=' . $token . '&try=' . $try . '";
363
  </script>';
 
 
 
 
 
 
364
  }
365
- $line .= __( 'Please note that if you have several profiles of the same website, it doesn\'t matter which profile you select, and in fact another profile might show as selected later. You can check whether they\'re profiles for the same site by checking if they have the same UA code. If that\'s true, tracking will be correct.', 'gawp' );
366
- $line .= '<br/><br/>';
367
- $line .= __( 'Refresh this listing or switch to another account: ', 'gawp' );
368
  } else {
369
  $line = __( 'Unfortunately, an error occurred while connecting to Google, please try again:', 'gawp' );
370
  }
317
  if ( !empty( $options['uastring'] ) )
318
  $currentua = $options['uastring'];
319
 
320
+ if ( isset( $arr['feed']['entry'] ) && is_array( $arr['feed']['entry'] ) ) {
321
+ // Check whether the feed output is the new one, first set, or the old one, second set.
322
+ if ( $arr['feed']['link_attr']['href'] == 'https://www.googleapis.com/analytics/v2.4/management/accounts/~all/webproperties/~all/profiles' ) {
323
+ if ( isset( $arr['feed']['entry']['id'] ) ) {
324
+ // Single account in the feed
325
+ if ( isset( $arr['feed']['entry']['dxp:property']['1_attr']['value'] ) )
326
+ $ua = trim( $arr['feed']['entry']['dxp:property']['1_attr']['value'] );
327
+ if ( isset( $arr['feed']['entry']['dxp:property']['2_attr']['value'] ) )
328
+ $title = trim( $arr['feed']['entry']['dxp:property']['2_attr']['value'] );
329
+ if ( !empty( $ua ) && !empty( $title ) )
330
+ $ga_accounts[$ua] = $title;
331
+ } else {
332
+ // Multiple accounts in the feed
333
+ foreach ( $arr['feed']['entry'] as $site ) {
334
+ if ( isset( $site['dxp:property']['1_attr']['value'] ) )
335
+ $ua = trim( $site['dxp:property']['1_attr']['value'] );
336
+ if ( isset( $site['dxp:property']['2_attr']['value'] ) )
337
+ $title = trim( $site['dxp:property']['2_attr']['value'] );
338
+ if ( !empty( $ua ) && !empty( $title ) )
339
+ $ga_accounts[$ua] = $title;
340
+ }
341
+ }
342
+ } else if ( $arr['feed']['link_attr']['href'] == 'https://www.google.com/analytics/feeds/accounts/default' ) {
343
+ foreach ( $arr['feed']['entry'] as $site ) {
344
+ if ( isset( $site['dxp:property']['3_attr']['value'] ) )
345
+ $ua = trim( $site['dxp:property']['3_attr']['value'] );
346
+ if ( isset( $site['dxp:property']['1_attr']['value'] ) )
347
+ $title = trim( $site['dxp:property']['1_attr']['value'] );
348
+ if ( !empty( $ua ) && !empty( $title ) )
349
+ $ga_accounts[$ua] = $title;
350
+ }
351
  }
352
+ asort( $ga_accounts );
 
 
 
 
 
 
 
 
 
 
353
 
354
+ $select = '<select class="chzn-select" name="uastring" data-placeholder="' . __( 'Please select the correct Analytics Account', 'gawp' ) . '" id="ga_account">';
355
+ $select .= "\t<option></option>\n";
356
+ foreach ( $ga_accounts as $ua => $title ) {
357
+ $sel = selected( $ua, $currentua, false );
358
+ $select .= "\t" . '<option ' . $sel . ' value="' . $ua . '">' . $title . ' - ' . $ua . '</option>' . "\n";
359
+ }
360
+ $select .= '</select>';
361
 
362
+ $line = '<input type="hidden" name="ga_token" value="' . $token . '"/>';
363
+ $line .= __( 'Please select the correct Analytics account to track:', 'gawp' ) . '<br/>';
364
+ $line .= '<table class="form_table">';
365
+ $line .= '<tr><th>' . __( 'Profile', 'gawp' ) . ':</th><td>' . $select . '</td></tr>';
366
+ $line .= '</table>';
367
 
368
+ $try = 1;
369
+ if ( isset( $_GET['try'] ) )
370
+ $try = $_GET['try'] + 1;
371
 
372
+ if ( count( $ga_accounts ) == 0 && $try < 4 && isset( $_GET['token'] ) ) {
373
+ $line .= '<script type="text/javascript">
374
  window.location="' . $this->plugin_options_url() . '&switchua=1&token=' . $token . '&try=' . $try . '";
375
  </script>';
376
+ }
377
+ $line .= __( 'Please note that if you have several profiles of the same website, it doesn\'t matter which profile you select, and in fact another profile might show as selected later. You can check whether they\'re profiles for the same site by checking if they have the same UA code. If that\'s true, tracking will be correct.', 'gawp' );
378
+ $line .= '<br/><br/>';
379
+ $line .= __( 'Refresh this listing or switch to another account: ', 'gawp' );
380
+ } else {
381
+ $line = __( 'Unfortunately, an error occurred while connecting to Google, please try again:', 'gawp' );
382
  }
 
 
 
383
  } else {
384
  $line = __( 'Unfortunately, an error occurred while connecting to Google, please try again:', 'gawp' );
385
  }
googleanalytics.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Analytics for WordPress
4
  Plugin URI: http://yoast.com/wordpress/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v420
5
  Description: This plugin makes it simple to add Google Analytics to your WordPress blog, adding lots of features, eg. custom variables and automatic clickout and download tracking.
6
  Author: Joost de Valk
7
- Version: 4.3.1
8
  Requires at least: 3.0
9
  Author URI: http://yoast.com/
10
  License: GPL v3
@@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 
29
  // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times.
30
 
31
- define( "GAWP_VERSION", '4.3.1' );
32
 
33
  define( "GAWP_URL", trailingslashit( plugin_dir_url( __FILE__ ) ) );
34
 
4
  Plugin URI: http://yoast.com/wordpress/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v420
5
  Description: This plugin makes it simple to add Google Analytics to your WordPress blog, adding lots of features, eg. custom variables and automatic clickout and download tracking.
6
  Author: Joost de Valk
7
+ Version: 4.3.2
8
  Requires at least: 3.0
9
  Author URI: http://yoast.com/
10
  License: GPL v3
28
 
29
  // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times.
30
 
31
+ define( "GAWP_VERSION", '4.3.2' );
32
 
33
  define( "GAWP_URL", trailingslashit( plugin_dir_url( __FILE__ ) ) );
34
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://yoast.com/donate/
4
  Tags: analytics, google analytics, statistics, tracking, stats, google
5
  Requires at least: 3.3
6
  Tested up to: 3.5
7
- Stable tag: 4.3.1
8
 
9
  Track your WordPress site easily and with lots of metadata: views per author & category, automatic tracking of outbound clicks and pageviews.
10
 
@@ -58,6 +58,10 @@ This section describes how to install the plugin and get it working.
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 4.3.1 =
62
 
63
  * Removes a left over JS alert.
4
  Tags: analytics, google analytics, statistics, tracking, stats, google
5
  Requires at least: 3.3
6
  Tested up to: 3.5
7
+ Stable tag: 4.3.2
8
 
9
  Track your WordPress site easily and with lots of metadata: views per author & category, automatic tracking of outbound clicks and pageviews.
10
 
58
 
59
  == Changelog ==
60
 
61
+ = 4.3.2 =
62
+
63
+ * Bugfix: Google Analytics crappy API output is different when you have a single GA account versus multiple. Annoying, but fixed now.
64
+
65
  = 4.3.1 =
66
 
67
  * Removes a left over JS alert.