Google Analytics for WordPress by MonsterInsights - Version 4.0.9

Version Description

  • Code enhancements:
    • Updated Shopp integration to also work with the upcoming Shopp 1.1 and higher.
    • Switched from split to explode, as split has been deprecated in PHP 5.3+.
  • New features:
    • A new debug mode has been added, using the new ga_debug.js. Along with this you can now enable Firebug Lite, so you can easily see the output from the debug script in each browser. Admins only, of course.
    • A list of modules has been added to the right sidebar, to allow easy navigation within the settings page.
Download this release

Release Info

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

Code changes from version 4.0.8 to 4.0.9

Files changed (3) hide show
  1. googleanalytics.php +55 -19
  2. readme.txt +45 -8
  3. screenshot-5.png +0 -0
googleanalytics.php CHANGED
@@ -4,12 +4,14 @@ 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=v407
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.0.8
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
11
  */
12
 
 
 
13
  // Determine the location
14
  function gapp_plugin_path() {
15
  return plugins_url('', __FILE__).'/';
@@ -109,19 +111,23 @@ if ( ! class_exists( 'GA_Admin' ) ) {
109
  jQuery('#trackoutbound').change(function(){
110
  if ((jQuery('#trackoutbound').attr('checked')) == true) {
111
  jQuery('#internallinktracking').css("display","block");
 
112
  } else {
113
  jQuery('#internallinktracking').css("display","none");
 
114
  }
115
  }).change();
116
  jQuery('#advancedsettings').change(function(){
117
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
118
  jQuery('#advancedgasettings').css("display","block");
119
  jQuery('#customvarsettings').css("display","block");
120
- jQuery('#toc').css("display","block");
 
121
  } else {
122
  jQuery('#advancedgasettings').css("display","none");
123
  jQuery('#customvarsettings').css("display","none");
124
- jQuery('#toc').css("display","none");
 
125
  }
126
  }).change();
127
  jQuery('#extrase').change(function(){
@@ -176,7 +182,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
176
  function toc( $modules ) {
177
  $output = '<ul>';
178
  foreach ($modules as $module => $key) {
179
- $output .= '<li><a href="#'.$key.'">'.$module.'</a></li>';
180
  }
181
  $output .= '</ul>';
182
  return $output;
@@ -199,7 +205,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
199
  $options[$option_name] = '';
200
  }
201
 
202
- 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', 'gajslocalhosting', 'manual_uastring', 'taggfsubmit', 'wpec_tracking', 'shopp_tracking', 'anonymizeip', 'trackcommentform') as $option_name) {
203
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
204
  $options[$option_name] = true;
205
  else
@@ -250,6 +256,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
250
  echo $options['msg'];
251
  $options['msg'] = '';
252
  update_option($this->optionname, $options);
 
253
 
254
  ?>
255
  <div class="wrap">
@@ -475,6 +482,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
475
  'content' => $this->checkbox('cv_all_categories'),
476
  );
477
 
 
478
  $this->postbox('customvarsettings','Custom Variables Settings',$pre_content.$this->form_table($rows).$this->save_button());
479
 
480
  $rows = array();
@@ -586,7 +594,7 @@ if ( ! class_exists( 'GA_Admin' ) ) {
586
  'desc' => 'This adds <code><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp">_anonymizeIp</a></code>, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.',
587
  'content' => $this->checkbox('anonymizeip'),
588
  );
589
-
590
  $this->postbox('advancedgasettings','Advanced Settings',$this->form_table($rows).$this->save_button());
591
 
592
  $rows = array();
@@ -602,11 +610,9 @@ if ( ! class_exists( 'GA_Admin' ) ) {
602
  'desc' => 'The label to use for these links, this will be added to where the click came from, so if the label is "aff", the label for a click from the content of an article becomes "outbound-article-aff".',
603
  'content' => $this->textinput('internallinklabel'),
604
  );
605
-
606
  $this->postbox('internallinktracking','Internal Links to Track as Outbound',$this->form_table($rows).$this->save_button());
607
 
608
- $modules = array();
609
-
610
  /* if (class_exists('RGForms') && GFCommon::$version >= '1.3.11') {
611
  $pre_content = 'This plugin can automatically tag your Gravity Forms to track form submissions as either events or pageviews';
612
  $rows = array();
@@ -651,7 +657,21 @@ if ( ! class_exists( 'GA_Admin' ) ) {
651
  $this->postbox('shoppecommerce','Shopp e-Commerce Settings',$pre_content.$this->form_table($rows).$this->save_button());
652
  $modules['Shopp'] = 'shoppecommerce';
653
  }
654
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
  </form>
656
  <form action="<?php echo $this->plugin_options_url(); ?>" method="post" onsubmit="javascript:return(confirm('Do you really want to reset all settings?'));">
657
  <input type="hidden" name="reset" value="true"/>
@@ -876,6 +896,8 @@ if ( ! class_exists( 'GA_Filter' ) ) {
876
  $pushstr .= "[".$key."]";
877
  }
878
 
 
 
879
  ?>
880
 
881
  <script type="text/javascript">//<![CDATA[
@@ -900,7 +922,10 @@ if ( ! class_exists( 'GA_Filter' ) ) {
900
  if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
901
  echo "'".$options['gajsurl']."';";
902
  } else {
903
- echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';";
 
 
 
904
  }
905
  ?>
906
 
@@ -908,7 +933,6 @@ if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
908
  })();
909
  // End of Google Analytics for WordPress by Yoast v4.0
910
  //]]></script>
911
-
912
  <?php
913
  } else if ( $options["uastring"] != "" ) {
914
  echo "<!-- Google Analytics tracking code not shown because users over level ".$options["ignore_userlevel"]." are ignored -->\n";
@@ -977,7 +1001,7 @@ if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
977
  }
978
  $trackBit = "";
979
  $extension = substr(strrchr($matches[3], '.'), 1);
980
- $dlextensions = split(",",str_replace('.','',$options['dlextensions']));
981
  if ( $target ) {
982
  if ( $target == 'email' ) {
983
  $trackBit = GA_Filter::ga_get_tracking_link('mailto', str_replace('mailto:','',$matches[3]),'');
@@ -1174,14 +1198,26 @@ if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
1174
 
1175
  function shopp_transaction_tracking( $push ) {
1176
  global $Shopp;
 
1177
  // Only process if we're in the checkout process (receipt page)
1178
- if (function_exists('is_shopp_page') && !is_shopp_page('checkout'))
1179
- return $push;
1180
- // Only process if we have valid order data
1181
- if (!isset($Shopp->Cart->data->Purchase) || empty($Shopp->Cart->data->Purchase->id))
1182
- return $push;
 
 
 
 
 
 
 
 
 
 
 
 
1183
 
1184
- $Purchase = $Shopp->Cart->data->Purchase;
1185
  $push[] = "'_addTrans',"
1186
  ."'".$Purchase->id."'," // Order ID
1187
  ."'".GA_Filter::ga_str_clean(get_bloginfo('name'))."'," // Store
4
  Plugin URI: http://yoast.com/wordpress/analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=google-analytics-for-wordpress&utm_content=v407
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.0.9
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
11
  */
12
 
13
+ // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics
14
+
15
  // Determine the location
16
  function gapp_plugin_path() {
17
  return plugins_url('', __FILE__).'/';
111
  jQuery('#trackoutbound').change(function(){
112
  if ((jQuery('#trackoutbound').attr('checked')) == true) {
113
  jQuery('#internallinktracking').css("display","block");
114
+ jQuery('.internallinktracking').css("display","list-item");
115
  } else {
116
  jQuery('#internallinktracking').css("display","none");
117
+ jQuery('.internallinktracking').css("display","none");
118
  }
119
  }).change();
120
  jQuery('#advancedsettings').change(function(){
121
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
122
  jQuery('#advancedgasettings').css("display","block");
123
  jQuery('#customvarsettings').css("display","block");
124
+ jQuery('.advancedgasettings').css("display","list-item");
125
+ jQuery('.customvarsettings').css("display","list-item");
126
  } else {
127
  jQuery('#advancedgasettings').css("display","none");
128
  jQuery('#customvarsettings').css("display","none");
129
+ jQuery('.advancedgasettings').css("display","none");
130
+ jQuery('.customvarsettings').css("display","none");
131
  }
132
  }).change();
133
  jQuery('#extrase').change(function(){
182
  function toc( $modules ) {
183
  $output = '<ul>';
184
  foreach ($modules as $module => $key) {
185
+ $output .= '<li class="'.$key.'"><a href="#'.$key.'">'.$module.'</a></li>';
186
  }
187
  $output .= '</ul>';
188
  return $output;
205
  $options[$option_name] = '';
206
  }
207
 
208
+ 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', 'gajslocalhosting', 'manual_uastring', 'taggfsubmit', 'wpec_tracking', 'shopp_tracking', 'anonymizeip', 'trackcommentform', 'debug','firebuglite') as $option_name) {
209
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
210
  $options[$option_name] = true;
211
  else
256
  echo $options['msg'];
257
  $options['msg'] = '';
258
  update_option($this->optionname, $options);
259
+ $modules = array();
260
 
261
  ?>
262
  <div class="wrap">
482
  'content' => $this->checkbox('cv_all_categories'),
483
  );
484
 
485
+ $modules['Custom Variables'] = 'customvarsettings';
486
  $this->postbox('customvarsettings','Custom Variables Settings',$pre_content.$this->form_table($rows).$this->save_button());
487
 
488
  $rows = array();
594
  'desc' => 'This adds <code><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp">_anonymizeIp</a></code>, telling Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage.',
595
  'content' => $this->checkbox('anonymizeip'),
596
  );
597
+ $modules['Advanced Settings'] = 'advancedgasettings';
598
  $this->postbox('advancedgasettings','Advanced Settings',$this->form_table($rows).$this->save_button());
599
 
600
  $rows = array();
610
  'desc' => 'The label to use for these links, this will be added to where the click came from, so if the label is "aff", the label for a click from the content of an article becomes "outbound-article-aff".',
611
  'content' => $this->textinput('internallinklabel'),
612
  );
613
+ $modules['Internal Link Tracking'] = 'internallinktracking';
614
  $this->postbox('internallinktracking','Internal Links to Track as Outbound',$this->form_table($rows).$this->save_button());
615
 
 
 
616
  /* if (class_exists('RGForms') && GFCommon::$version >= '1.3.11') {
617
  $pre_content = 'This plugin can automatically tag your Gravity Forms to track form submissions as either events or pageviews';
618
  $rows = array();
657
  $this->postbox('shoppecommerce','Shopp e-Commerce Settings',$pre_content.$this->form_table($rows).$this->save_button());
658
  $modules['Shopp'] = 'shoppecommerce';
659
  }
660
+ $pre_content = '<p>If you want to confirm that tracking on your blog is working as it should, enable this option and check the console in <a href="http://getfirebug.com/">Firebug</a> (for Firefox), <a href="http://getfirebug.com/firebuglite">Firebug Lite</a> (for other browsers) or Chrome &amp; Safari\'s Web Inspector. Be absolutely sure to disable debugging afterwards, as it is slower than normal tracking.</p><p><strong>Note</strong>: the debugging and firebug scripts are only loaded for admins.</p>';
661
+ $rows = array();
662
+ $rows[] = array(
663
+ 'id' => 'debug',
664
+ 'label' => 'Enable debug mode',
665
+ 'content' => $this->checkbox('debug'),
666
+ );
667
+ $rows[] = array(
668
+ 'id' => 'firebuglite',
669
+ 'label' => 'Enable Firebug Lite',
670
+ 'content' => $this->checkbox('firebuglite'),
671
+ );
672
+ $this->postbox('debugmode','Debug Mode',$pre_content.$this->form_table($rows).$this->save_button());
673
+ $modules['Debug Mode'] = 'debugmode';
674
+ ?>
675
  </form>
676
  <form action="<?php echo $this->plugin_options_url(); ?>" method="post" onsubmit="javascript:return(confirm('Do you really want to reset all settings?'));">
677
  <input type="hidden" name="reset" value="true"/>
896
  $pushstr .= "[".$key."]";
897
  }
898
 
899
+ if ( current_user_can('manage_options') && $options['firebuglite'] && $options['debug'] )
900
+ echo '<script src="https://getfirebug.com/firebug-lite.js" type="text/javascript"></script>';
901
  ?>
902
 
903
  <script type="text/javascript">//<![CDATA[
922
  if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
923
  echo "'".$options['gajsurl']."';";
924
  } else {
925
+ $script = 'ga.js';
926
+ if ( current_user_can('manage_options') && $options['debug'] )
927
+ $script = 'u/ga_debug.js';
928
+ echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/".$script."';";
929
  }
930
  ?>
931
 
933
  })();
934
  // End of Google Analytics for WordPress by Yoast v4.0
935
  //]]></script>
 
936
  <?php
937
  } else if ( $options["uastring"] != "" ) {
938
  echo "<!-- Google Analytics tracking code not shown because users over level ".$options["ignore_userlevel"]." are ignored -->\n";
1001
  }
1002
  $trackBit = "";
1003
  $extension = substr(strrchr($matches[3], '.'), 1);
1004
+ $dlextensions = explode(",",str_replace('.','',$options['dlextensions']));
1005
  if ( $target ) {
1006
  if ( $target == 'email' ) {
1007
  $trackBit = GA_Filter::ga_get_tracking_link('mailto', str_replace('mailto:','',$matches[3]),'');
1198
 
1199
  function shopp_transaction_tracking( $push ) {
1200
  global $Shopp;
1201
+
1202
  // Only process if we're in the checkout process (receipt page)
1203
+ if (version_compare(substr(SHOPP_VERSION,0,3),'1.1') >= 0) {
1204
+ // Only process if we're in the checkout process (receipt page)
1205
+ if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) return $push;
1206
+ if (empty($Shopp->Order->purchase)) return $push;
1207
+
1208
+ $Purchase = new Purchase($Shopp->Order->purchase);
1209
+ $Purchase->load_purchased();
1210
+ } else {
1211
+ // For 1.0.x
1212
+ // Only process if we're in the checkout process (receipt page)
1213
+ if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) return $push;
1214
+ // Only process if we have valid order data
1215
+ if (!isset($Shopp->Cart->data->Purchase)) return $push;
1216
+ if (empty($Shopp->Cart->data->Purchase->id)) return $push;
1217
+
1218
+ $Purchase = $Shopp->Cart->data->Purchase;
1219
+ }
1220
 
 
1221
  $push[] = "'_addTrans',"
1222
  ."'".$Purchase->id."'," // Order ID
1223
  ."'".GA_Filter::ga_str_clean(get_bloginfo('name'))."'," // Store
readme.txt CHANGED
@@ -4,17 +4,45 @@ 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.8
8
 
9
- The Google Analytics for WordPress plugin allows you to track your blog easily and with lots of metadata. 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 allow 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
 
11
  == Description ==
12
 
13
- The Google Analytics for WordPress plugin allows you to track your blog easily and with lots of metadata. 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 allow 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!
14
-
15
- For the full list of features, check out the [Google Analytics for WordPress](http://yoast.com/wordpress/google-analytics/) homepage.
16
-
17
- * Other [Wordpress plugins](http://yoast.com/wordpress/) by the same author.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  * Want to increase traffic to your WordPress blog? Check out the [WordPress SEO](http://yoast.com/articles/wordpress-seo/) Guide!
19
  * Check out the authors [WordPress Hosting](http://yoast.com/articles/wordpress-hosting/) experience. Good hosting is hard to come by, but it doesn't have to be expensive, Joost tells you why!
20
  * If you've still not seen enough, or you'd rather listen than read, check out the [WordPress Podcast](http://wp-community.org/), hosted by the author of this plugin and Frederick Townes, the creator of [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/).
@@ -30,6 +58,14 @@ This section describes how to install the plugin and get it working.
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
 
 
 
33
  = 4.0.8 =
34
  * Reverted double quote change from 4.0.7 because it was causing bigger issues.
35
 
@@ -226,4 +262,5 @@ Because that's where it belongs. It makes the page load faster (yes, faster, due
226
  1. Screenshot of the basic settings panel for this plugin.
227
  2. Screenshot of the custom variable settings panel.
228
  3. Screenshot of the link tracking panel.
229
- 4. Screenshot of the advanced settings panel.
 
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.9
8
 
9
+ Track your WordPress site easily and with lots of metadata: views per author & category, automatic tracking of outbound clicks and pageviews.
10
 
11
  == Description ==
12
 
13
+ The Google Analytics for WordPress plugin allows you to track your blog easily and with lots of metadata.
14
+
15
+ Check out the [Google Analytics for WordPress video](http://www.youtube.com/watch?v=tnUXzbvXxSQ):
16
+
17
+ http://www.youtube.com/watch?v=tnUXzbvXxSQ&hd=1
18
+
19
+ Full list of features:
20
+
21
+ * Simple installation through integration with Google Analytics API: authenticate, select the site you want to track and you're done.
22
+ * This plugin uses the asynchronous tracking code, the fastest and most reliable tracking code Google Analytics offers.
23
+ * Option to manually place the tracking code in another location.
24
+ * Outbound link & downloads tracking.
25
+ * Configurable options to track outbound links either as pageviews.
26
+ * Option to track just downloads as pageviews.
27
+ * Allows usage of custom variables to track meta data on pages. Support for the following custom variables:
28
+ * Author
29
+ * Single category and / or multiple categories
30
+ * Post type (especially useful if you use custom post types)
31
+ * Logged in users
32
+ * Publication Year
33
+ * Tags
34
+ * Possibility to ignore any user level and up, so all editors and higher for instance.
35
+ * Easily connect your AdSense and Analytics accounts.
36
+ * Option to tag links with campaign tracking, with the option to use hashes (#).
37
+ * Option anonymize IP's, for use in countries like Germany.
38
+ * Full [debug mode](http://yoast.com/google-analytics-debug-mode/), including Firebug lite and ga_debug.js for debugging Analytics issues.
39
+ * Allow local hosting of ga.js file.
40
+ * Tracking non default search engines
41
+ * Tracking of login and registration forms.
42
+
43
+ Other interesting stuff:
44
+
45
+ * Check out the other [Wordpress plugins](http://yoast.com/wordpress/) by the same author.
46
  * Want to increase traffic to your WordPress blog? Check out the [WordPress SEO](http://yoast.com/articles/wordpress-seo/) Guide!
47
  * Check out the authors [WordPress Hosting](http://yoast.com/articles/wordpress-hosting/) experience. Good hosting is hard to come by, but it doesn't have to be expensive, Joost tells you why!
48
  * If you've still not seen enough, or you'd rather listen than read, check out the [WordPress Podcast](http://wp-community.org/), hosted by the author of this plugin and Frederick Townes, the creator of [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/).
58
 
59
  == Changelog ==
60
 
61
+ = 4.0.9 =
62
+ * Code enhancements:
63
+ * Updated Shopp integration to also work with the upcoming Shopp 1.1 and higher.
64
+ * Switched from [split](http://php.net/split) to [explode](http://php.net/explode), as split has been deprecated in PHP 5.3+.
65
+ * New features:
66
+ * A new debug mode has been added, using the new [ga_debug.js](http://analytics.blogspot.com/2010/08/new-tools-to-debug-your-tracking-code.html). Along with this you can now enable Firebug Lite, so you can easily see the output from the debug script in each browser. Admins only, of course.
67
+ * A list of modules has been added to the right sidebar, to allow easy navigation within the settings page.
68
+
69
  = 4.0.8 =
70
  * Reverted double quote change from 4.0.7 because it was causing bigger issues.
71
 
262
  1. Screenshot of the basic settings panel for this plugin.
263
  2. Screenshot of the custom variable settings panel.
264
  3. Screenshot of the link tracking panel.
265
+ 4. Screenshot of the advanced settings panel.
266
+ 5. Screenshot of the debugging mode in action.
screenshot-5.png ADDED
Binary file