Google Analytics for WordPress by MonsterInsights - Version 4.0.3

Version Description

  • New features in this release:
    • Added versioning to the options array, to allow for easy addition of options.
    • Added an option to enable comment form tracking (as this loads jQuery), defaults to on.
  • Bugs fixed:
    • If you upgraded from before 4.0 to 4.0.2 you might have an empty value for ignore_userlevel in some edge cases, this is now fixed.
    • Custom search engines were loaded after trackPageview, this was wrong as shown by these docs, now fixed.
Download this release

Release Info

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

Code changes from version 4.0.2 to 4.0.3

Files changed (2) hide show
  1. googleanalytics.php +37 -12
  2. readme.txt +9 -1
googleanalytics.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /*
3
  Plugin Name: Google Analytics for WordPress
4
- Plugin URI: http://yoast.com/wordpress/analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=google-analytics-for-wordpress&utm_content=v40
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
- Version: 4.0.2
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
@@ -36,6 +36,8 @@ if ( ! class_exists( 'GA_Admin' ) ) {
36
  var $toc = '';
37
 
38
  function GA_Admin() {
 
 
39
  add_action( 'admin_menu', array(&$this, 'register_settings_page') );
40
  add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
41
  add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
@@ -177,7 +179,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
177
  $options[$option_name] = '';
178
  }
179
 
180
- foreach (array('extrase', 'trackoutbound', 'admintracking', 'trackadsense', 'allowanchor', 'allowlinker', 'rsslinktagging', 'advancedsettings', 'trackregistration', 'theme_updated', 'cv_loggedin', 'cv_authorname', 'cv_category', 'cv_all_categories', 'cv_tags', 'cv_year', 'cv_post_type', 'outboundpageview', 'downloadspageview', 'manual_uastring', 'taggfsubmit', 'wpec_tracking', 'shopp_tracking', 'anonymizeip') as $option_name) {
181
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
182
  $options[$option_name] = true;
183
  else
@@ -198,11 +200,25 @@ if ( ! class_exists( 'GA_Admin' ) ) {
198
  return '<div class="alignright"><input type="submit" class="button-primary" name="submit" value="Update Google Analytics Settings &raquo;" /></div><br class="clear"/>';
199
  }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  function config_page() {
202
  $options = get_option($this->optionname);
203
  echo $options['msg'];
204
  $options['msg'] = '';
205
  update_option($this->optionname, $options);
 
206
  ?>
207
  <div class="wrap">
208
  <a href="http://yoast.com/"><div id="yoast-icon" style="background: url(http://cdn.yoast.com/wp-content/themes/yoast-v2/images/yoast-32x32.png) no-repeat;" class="icon32"><br /></div></a>
@@ -505,6 +521,11 @@ if ( ! class_exists( 'GA_Admin' ) ) {
505
  'label' => 'Add tracking to the login and registration forms',
506
  'content' => $this->checkbox('trackregistration'),
507
  );
 
 
 
 
 
508
  $rows[] = array(
509
  'id' => 'allowanchor',
510
  'label' => 'Use # instead of ? for Campaign tracking',
@@ -644,6 +665,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
644
  'outboundpageview' => false,
645
  'downloadspageview' => false,
646
  'position' => 'footer',
 
647
  'trackadsense' => false,
648
  'trackoutbound' => true,
649
  'trackregistration' => false,
@@ -693,7 +715,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
693
  * The order of custom variables is very, very important: custom vars should always take up the same slot to make analysis easy.
694
  */
695
  $customvarslot = 1;
696
- if ( $options["uastring"] != "" && !($current_user->user_level >= $options["ignore_userlevel"]) && !is_preview() ) {
697
  $push = array();
698
 
699
  if ( $options['allowanchor'] )
@@ -818,7 +840,6 @@ if ( ! class_exists( 'GA_Filter' ) ) {
818
  <script type="text/javascript">//<![CDATA[
819
  var _gaq = _gaq || [];
820
  _gaq.push(['_setAccount','<?php echo $options["uastring"]; ?>']);
821
- _gaq.push(<?php echo $pushstr; ?>);
822
  <?php
823
  if ( $options["extrase"] ) {
824
  if ( !empty($options["extraseurl"]) ) {
@@ -829,7 +850,9 @@ if ( ! class_exists( 'GA_Filter' ) ) {
829
  echo '</script><script src="'.$url.'" type="text/javascript"></script>'."\n".'<script type="text/javascript">';
830
  }
831
 
832
- ?> (function() {
 
 
833
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
834
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
835
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
@@ -849,7 +872,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
849
  */
850
  function spool_adsense() {
851
  $options = get_option('Yoast_Google_Analytics');
852
- if ( $options["uastring"] != "" && !($current_user->user_level >= $options["ignore_userlevel"]) && !is_preview() ) {
853
  echo '<script type="text/javascript">'."\n";
854
  echo "\t".'window.google_analytics_uacct = "'.$options["uastring"].'";'."\n";
855
  echo '</script>'."\n";
@@ -960,7 +983,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
960
  function widget_content($text) {
961
  global $current_user;
962
  $options = get_option('Yoast_Google_Analytics');
963
- if ($current_user->user_level >= $options["ignore_userlevel"])
964
  return $text;
965
  static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';
966
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_widget_link'),$text);
@@ -970,7 +993,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
970
  function the_content($text) {
971
  global $current_user;
972
  $options = get_option('Yoast_Google_Analytics');
973
- if ($current_user->user_level >= $options["ignore_userlevel"])
974
  return $text;
975
 
976
  if (!is_feed()) {
@@ -983,7 +1006,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
983
  function comment_text($text) {
984
  global $current_user;
985
  $options = get_option('Yoast_Google_Analytics');
986
- if ($current_user->user_level >= $options["ignore_userlevel"])
987
  return $text;
988
 
989
  if (!is_feed()) {
@@ -996,7 +1019,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
996
  function comment_author_link($text) {
997
  global $current_user;
998
  $options = get_option('Yoast_Google_Analytics');
999
- if ($current_user->user_level >= $options["ignore_userlevel"])
1000
  return $text;
1001
 
1002
  static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
@@ -1018,7 +1041,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
1018
  function bookmarks($bookmarks) {
1019
  global $current_user;
1020
  $options = get_option('Yoast_Google_Analytics');
1021
- if ($current_user->user_level >= $options["ignore_userlevel"])
1022
  return $bookmarks;
1023
 
1024
  $i = 0;
@@ -1263,6 +1286,8 @@ if (!is_array($options)) {
1263
  if ($options['admintracking']) {
1264
  $options["ignore_userlevel"] = '8';
1265
  unset($options['admintracking']);
 
 
1266
  }
1267
  update_option('Yoast_Google_Analytics', $options);
1268
  }
1
  <?php
2
  /*
3
  Plugin Name: Google Analytics for WordPress
4
+ Plugin URI: http://yoast.com/wordpress/analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=google-analytics-for-wordpress&utm_content=v403
5
  Description: This plugin makes it simple to add Google Analytics with extra search engines and automatic clickout and download tracking to your WordPress blog.
6
  Author: Joost de Valk
7
+ Version: 4.0.3
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
36
  var $toc = '';
37
 
38
  function GA_Admin() {
39
+ $this->upgrade();
40
+
41
  add_action( 'admin_menu', array(&$this, 'register_settings_page') );
42
  add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
43
  add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
179
  $options[$option_name] = '';
180
  }
181
 
182
+ foreach (array('extrase', 'trackoutbound', 'admintracking', 'trackadsense', 'allowanchor', 'allowlinker', 'rsslinktagging', 'advancedsettings', 'trackregistration', 'theme_updated', 'cv_loggedin', 'cv_authorname', 'cv_category', 'cv_all_categories', 'cv_tags', 'cv_year', 'cv_post_type', 'outboundpageview', 'downloadspageview', 'manual_uastring', 'taggfsubmit', 'wpec_tracking', 'shopp_tracking', 'anonymizeip', 'trackcommentform') as $option_name) {
183
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
184
  $options[$option_name] = true;
185
  else
200
  return '<div class="alignright"><input type="submit" class="button-primary" name="submit" value="Update Google Analytics Settings &raquo;" /></div><br class="clear"/>';
201
  }
202
 
203
+ function upgrade() {
204
+ $options = get_option($this->optionname);
205
+ if ($options['version'] == '') {
206
+ if ( !isset($options['trackcommentform']) || $options['trackcommentform'] == '')
207
+ $options['trackcommentform'] = true;
208
+ if ( !isset($options['ignore_userlevel']) || $options['ignore_userlevel'] == '')
209
+ $options['ignore_userlevel'] = 11;
210
+
211
+ $options['version'] = '4.0.2';
212
+ }
213
+ update_option($this->optionname, $options);
214
+ }
215
+
216
  function config_page() {
217
  $options = get_option($this->optionname);
218
  echo $options['msg'];
219
  $options['msg'] = '';
220
  update_option($this->optionname, $options);
221
+
222
  ?>
223
  <div class="wrap">
224
  <a href="http://yoast.com/"><div id="yoast-icon" style="background: url(http://cdn.yoast.com/wp-content/themes/yoast-v2/images/yoast-32x32.png) no-repeat;" class="icon32"><br /></div></a>
521
  'label' => 'Add tracking to the login and registration forms',
522
  'content' => $this->checkbox('trackregistration'),
523
  );
524
+ $rows[] = array(
525
+ 'id' => 'trackcommentform',
526
+ 'label' => 'Add tracking to the comment forms',
527
+ 'content' => $this->checkbox('trackcommentform'),
528
+ );
529
  $rows[] = array(
530
  'id' => 'allowanchor',
531
  'label' => 'Use # instead of ? for Campaign tracking',
665
  'outboundpageview' => false,
666
  'downloadspageview' => false,
667
  'position' => 'footer',
668
+ 'trackcommentform' => true,
669
  'trackadsense' => false,
670
  'trackoutbound' => true,
671
  'trackregistration' => false,
715
  * The order of custom variables is very, very important: custom vars should always take up the same slot to make analysis easy.
716
  */
717
  $customvarslot = 1;
718
+ if ( $options["uastring"] != "" && !( is_numeric($options["ignore_userlevel"]) || $current_user->user_level >= $options["ignore_userlevel"]) && !is_preview() ) {
719
  $push = array();
720
 
721
  if ( $options['allowanchor'] )
840
  <script type="text/javascript">//<![CDATA[
841
  var _gaq = _gaq || [];
842
  _gaq.push(['_setAccount','<?php echo $options["uastring"]; ?>']);
 
843
  <?php
844
  if ( $options["extrase"] ) {
845
  if ( !empty($options["extraseurl"]) ) {
850
  echo '</script><script src="'.$url.'" type="text/javascript"></script>'."\n".'<script type="text/javascript">';
851
  }
852
 
853
+ ?>
854
+ _gaq.push(<?php echo $pushstr; ?>);
855
+ (function() {
856
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
857
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
858
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
872
  */
873
  function spool_adsense() {
874
  $options = get_option('Yoast_Google_Analytics');
875
+ if ( $options["uastring"] != "" && !(is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"]) && !is_preview() ) {
876
  echo '<script type="text/javascript">'."\n";
877
  echo "\t".'window.google_analytics_uacct = "'.$options["uastring"].'";'."\n";
878
  echo '</script>'."\n";
983
  function widget_content($text) {
984
  global $current_user;
985
  $options = get_option('Yoast_Google_Analytics');
986
+ if (is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"])
987
  return $text;
988
  static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';
989
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_widget_link'),$text);
993
  function the_content($text) {
994
  global $current_user;
995
  $options = get_option('Yoast_Google_Analytics');
996
+ if (is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"])
997
  return $text;
998
 
999
  if (!is_feed()) {
1006
  function comment_text($text) {
1007
  global $current_user;
1008
  $options = get_option('Yoast_Google_Analytics');
1009
+ if (is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"])
1010
  return $text;
1011
 
1012
  if (!is_feed()) {
1019
  function comment_author_link($text) {
1020
  global $current_user;
1021
  $options = get_option('Yoast_Google_Analytics');
1022
+ if (is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"])
1023
  return $text;
1024
 
1025
  static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
1041
  function bookmarks($bookmarks) {
1042
  global $current_user;
1043
  $options = get_option('Yoast_Google_Analytics');
1044
+ if (is_numeric($options["ignore_userlevel"]) && $current_user->user_level >= $options["ignore_userlevel"])
1045
  return $bookmarks;
1046
 
1047
  $i = 0;
1286
  if ($options['admintracking']) {
1287
  $options["ignore_userlevel"] = '8';
1288
  unset($options['admintracking']);
1289
+ } else {
1290
+ $options["ignore_userlevel"] = '11';
1291
  }
1292
  update_option('Yoast_Google_Analytics', $options);
1293
  }
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: 2.8
6
  Tested up to: 3.0
7
- Stable tag: 4.0.2
8
 
9
  The Google Analytics for WordPress plugin allows you to track your blog easily. It adds the asynchronous tracking code for Google Analytics and automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It'll add custom variables while tracking to show you pageviews per author, post type, category or publication year. It'll also allows you to track AdSense clicks, add extra search engines, ignore certain user levels, and much much more: this is simply the Ultimate Google Analytic solution for WP!
10
 
@@ -29,6 +29,14 @@ This section describes how to install the plugin and get it working.
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
 
 
 
32
  = 4.0.2 =
33
  * Old settings from versions below 4.0 are now properly sanitized and inherited (slaps forehead about simplicity of fix).
34
  * New features in this release:
4
  Tags: analytics, google analytics, statistics, tracking, stats, google
5
  Requires at least: 2.8
6
  Tested up to: 3.0
7
+ Stable tag: 4.0.3
8
 
9
  The Google Analytics for WordPress plugin allows you to track your blog easily. It adds the asynchronous tracking code for Google Analytics and automatically tracks and segments all outbound links from within posts, comment author links, links within comments, blogroll links and downloads. It'll add custom variables while tracking to show you pageviews per author, post type, category or publication year. It'll also allows you to track AdSense clicks, add extra search engines, ignore certain user levels, and much much more: this is simply the Ultimate Google Analytic solution for WP!
10
 
29
 
30
  == Changelog ==
31
 
32
+ = 4.0.3 =
33
+ * New features in this release:
34
+ * Added versioning to the options array, to allow for easy addition of options.
35
+ * Added an option to enable comment form tracking (as this loads jQuery), defaults to on.
36
+ * Bugs fixed:
37
+ * If you upgraded from before 4.0 to 4.0.2 you might have an empty value for ignore_userlevel in some edge cases, this is now fixed.
38
+ * Custom search engines were loaded after trackPageview, this was wrong as shown [by these docs](http://code.google.com/intl/sr/apis/analytics/docs/tracking/asyncMigrationExamples.html#SearchEngines), now fixed.
39
+
40
  = 4.0.2 =
41
  * Old settings from versions below 4.0 are now properly sanitized and inherited (slaps forehead about simplicity of fix).
42
  * New features in this release: