Google Analytics for WordPress by MonsterInsights - Version 4.0.10

Version Description

  • Known issues:

    • Authentication with Google gives errors in quite a few cases. Please use the manual option to add your UA code until we find a way to reliably fix it.
  • Added functionality:

    • Option to set _setAllowHash to false, for proper subdomain tracking and some other uses.
    • Option to add a custom string of code to the tracking, before the push string is sent out.
  • Documentation fixes:

    • Fixed link for _setDomainName().
    • Fixed some grammatical errors (keep emailing me about those, please!)
    • Removed second comment in source output.
    • Fixed version number output in source.
Download this release

Release Info

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

Code changes from version 4.0.9 to 4.0.10

Files changed (2) hide show
  1. googleanalytics.php +52 -19
  2. readme.txt +20 -2
googleanalytics.php CHANGED
@@ -4,7 +4,7 @@ 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.9
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
@@ -51,6 +51,9 @@ if ( ! class_exists( 'GA_Admin' ) ) {
51
  add_action('admin_head', array(&$this,'config_page_head'));
52
 
53
  add_action('admin_footer', array(&$this,'warning'));
 
 
 
54
  add_action('admin_footer', array(&$this,'theme_switch_warning'));
55
 
56
  add_action('admin_init', array(&$this,'save_settings'));
@@ -164,7 +167,21 @@ if ( ! class_exists( 'GA_Admin' ) ) {
164
  <?php
165
  }
166
  }
167
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  function theme_switch_warning() {
169
  $options = get_option( $this->optionname );
170
  if ($options['theme_updated']) {
@@ -198,14 +215,14 @@ if ( ! class_exists( 'GA_Admin' ) ) {
198
  if (!current_user_can('manage_options')) die(__('You cannot edit the Google Analytics for WordPress options.'));
199
  check_admin_referer('analyticspp-config');
200
 
201
- foreach (array('uastring', 'dlextensions', 'domainorurl','position','domain', 'ga_token', 'extraseurl', 'gajsurl', 'gfsubmiteventpv', 'trackprefix', 'ignore_userlevel', 'internallink', 'internallinklabel') as $option_name) {
202
  if (isset($_POST[$option_name]))
203
  $options[$option_name] = $_POST[$option_name];
204
  else
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
@@ -242,11 +259,9 @@ if ( ! class_exists( 'GA_Admin' ) ) {
242
  $options['trackcommentform'] = true;
243
  if ( !isset($options['ignore_userlevel']) || $options['ignore_userlevel'] == '')
244
  $options['ignore_userlevel'] = 11;
245
-
246
- $options['version'] = '4.04';
247
  }
248
- if ($options['version'] < '4.06') {
249
- $options['version'] = '4.06';
250
  }
251
  update_option($this->optionname, $options);
252
  }
@@ -502,13 +517,13 @@ if ( ! class_exists( 'GA_Admin' ) ) {
502
  $rows[] = array(
503
  'id' => 'outboundpageview',
504
  'label' => 'Track outbound clicks as pageviews',
505
- 'desc' => 'You do not need to enable this to enable outbound click tracking, this changes the default behavior of tracking clicks as events to tracking them as pageviews. This is therefore not recommended, as this would schew your statistics, but <em>is</em> sometimes necessary when you need to set outbound clicks as goals.',
506
  'content' => $this->checkbox('outboundpageview'),
507
  );
508
  $rows[] = array(
509
  'id' => 'downloadspageview',
510
  'label' => 'Track downloads as pageviews',
511
- 'desc' => 'Not recommended, as this would schew your statistics, but it does make it possible to track downloads as goals.',
512
  'content' => $this->checkbox('downloadspageview'),
513
  );
514
  $rows[] = array(
@@ -516,12 +531,14 @@ if ( ! class_exists( 'GA_Admin' ) ) {
516
  'label' => 'Extensions of files to track as downloads',
517
  'content' => $this->textinput('dlextensions'),
518
  );
519
- $rows[] = array(
520
- 'id' => 'trackprefix',
521
- 'label' => 'Prefix to use in Analytics before the tracked pageviews',
522
- 'desc' => 'This prefix is used before all pageviews, they are then segmented automatically after that. If nothing is entered here, <code>/yoast-ga/</code> is used.',
523
- 'content' => $this->textinput('trackprefix'),
524
- );
 
 
525
  $rows[] = array(
526
  'id' => 'domainorurl',
527
  'label' => 'Track full URL of outbound clicks or just the domain',
@@ -534,9 +551,15 @@ if ( ! class_exists( 'GA_Admin' ) ) {
534
  $rows[] = array(
535
  'id' => 'domain',
536
  'label' => 'Domain Tracking',
537
- 'desc' => 'This allows you to set the domain that\'s set by <a href="http://code.google.com/apis/analytics/docs/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setDomainName"><code>setDomainName</code></a> for tracking subdomains, if empty this will not be set.',
538
  'content' => $this->textinput('domain'),
539
  );
 
 
 
 
 
 
540
  $rows[] = array(
541
  'id' => 'trackadsense',
542
  'label' => 'Track AdSense',
@@ -588,6 +611,12 @@ if ( ! class_exists( 'GA_Admin' ) ) {
588
  'desc' => 'This adds a <code><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setAllowLinker">_setAllowLinker</a></code> call to your tracking code, allowing you to use <code>_link</code> and related functions.',
589
  'content' => $this->checkbox('allowlinker'),
590
  );
 
 
 
 
 
 
591
  $rows[] = array(
592
  'id' => 'anonymizeip',
593
  'label' => 'Anonymize IP\'s',
@@ -793,7 +822,10 @@ if ( ! class_exists( 'GA_Filter' ) ) {
793
  if (substr($options['domain'],0,1) != "." && $options['domain'] != 'none')
794
  $options['domain'] = ".".$options['domain'];
795
  $push[] = "'_setDomainName','".$options['domain']."'";
796
- }
 
 
 
797
 
798
  if ( $options['cv_loggedin'] ) {
799
  $current_user = wp_get_current_user();
@@ -914,6 +946,8 @@ if ( ! class_exists( 'GA_Filter' ) ) {
914
  echo '</script><script src="'.$url.'" type="text/javascript"></script>'."\n".'<script type="text/javascript">';
915
  }
916
 
 
 
917
  ?>
918
  _gaq.push(<?php echo $pushstr; ?>);
919
  (function() {
@@ -931,7 +965,6 @@ if ( $options['gajslocalhosting'] && !empty($options['gajsurl']) ) {
931
 
932
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
933
  })();
934
- // End of Google Analytics for WordPress by Yoast v4.0
935
  //]]></script>
936
  <?php
937
  } else if ( $options["uastring"] != "" ) {
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.10
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
51
  add_action('admin_head', array(&$this,'config_page_head'));
52
 
53
  add_action('admin_footer', array(&$this,'warning'));
54
+
55
+ add_action('contextual_help', array(&$this,'plugin_help'), 10, 3);
56
+
57
  add_action('admin_footer', array(&$this,'theme_switch_warning'));
58
 
59
  add_action('admin_init', array(&$this,'save_settings'));
167
  <?php
168
  }
169
  }
170
+
171
+ function plugin_help($contextual_help, $screen_id, $screen) {
172
+ if ($screen_id == $this->hook) {
173
+
174
+ $contextual_help = '<p>To use this WordPress Plugin, you must select from the following options:</p>
175
+ <ul>
176
+ <li><strong>Option 1:</strong> This is Option 1 features.</li>
177
+ <li><strong>Option 2:</strong> This is Option 2 features.</li>
178
+ <li><strong>Option 3:</strong> This is Option 3 features.</li>
179
+ </ul>
180
+ <p>When you have made your choice, click apply.</p>';
181
+ }
182
+ return $contextual_help;
183
+ }
184
+
185
  function theme_switch_warning() {
186
  $options = get_option( $this->optionname );
187
  if ($options['theme_updated']) {
215
  if (!current_user_can('manage_options')) die(__('You cannot edit the Google Analytics for WordPress options.'));
216
  check_admin_referer('analyticspp-config');
217
 
218
+ foreach (array('uastring', 'dlextensions', 'domainorurl','position','domain', 'customcode', 'ga_token', 'extraseurl', 'gajsurl', 'gfsubmiteventpv', 'trackprefix', 'ignore_userlevel', 'internallink', 'internallinklabel') as $option_name) {
219
  if (isset($_POST[$option_name]))
220
  $options[$option_name] = $_POST[$option_name];
221
  else
222
  $options[$option_name] = '';
223
  }
224
 
225
+ foreach (array('extrase', 'trackoutbound', 'admintracking', 'trackadsense', 'allowanchor', 'allowlinker', 'allowhash', '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) {
226
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
227
  $options[$option_name] = true;
228
  else
259
  $options['trackcommentform'] = true;
260
  if ( !isset($options['ignore_userlevel']) || $options['ignore_userlevel'] == '')
261
  $options['ignore_userlevel'] = 11;
 
 
262
  }
263
+ if ($options['version'] != '4.0.10') {
264
+ $options['version'] = '4.0.10';
265
  }
266
  update_option($this->optionname, $options);
267
  }
517
  $rows[] = array(
518
  'id' => 'outboundpageview',
519
  'label' => 'Track outbound clicks as pageviews',
520
+ 'desc' => 'You do not need to enable this to enable outbound click tracking, this changes the default behavior of tracking clicks as events to tracking them as pageviews. This is therefore not recommended, as this would skew your statistics, but <em>is</em> sometimes necessary when you need to set outbound clicks as goals.',
521
  'content' => $this->checkbox('outboundpageview'),
522
  );
523
  $rows[] = array(
524
  'id' => 'downloadspageview',
525
  'label' => 'Track downloads as pageviews',
526
+ 'desc' => 'Not recommended, as this would skew your statistics, but it does make it possible to track downloads as goals.',
527
  'content' => $this->checkbox('downloadspageview'),
528
  );
529
  $rows[] = array(
531
  'label' => 'Extensions of files to track as downloads',
532
  'content' => $this->textinput('dlextensions'),
533
  );
534
+ if ( $options['outboundpageview'] ) {
535
+ $rows[] = array(
536
+ 'id' => 'trackprefix',
537
+ 'label' => 'Prefix to use in Analytics before the tracked pageviews',
538
+ 'desc' => 'This prefix is used before all pageviews, they are then segmented automatically after that. If nothing is entered here, <code>/yoast-ga/</code> is used.',
539
+ 'content' => $this->textinput('trackprefix'),
540
+ );
541
+ }
542
  $rows[] = array(
543
  'id' => 'domainorurl',
544
  'label' => 'Track full URL of outbound clicks or just the domain',
551
  $rows[] = array(
552
  'id' => 'domain',
553
  'label' => 'Domain Tracking',
554
+ 'desc' => 'This allows you to set the domain that\'s set by <a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setDomainName"><code>setDomainName</code></a> for tracking subdomains, if empty this will not be set.',
555
  'content' => $this->textinput('domain'),
556
  );
557
+ $rows[] = array(
558
+ 'id' => 'customcode',
559
+ 'label' => 'Custom Code',
560
+ 'desc' => 'Not for the average user: this allows you to add a line of code, to be added before the <code>trackPageview</code> call.',
561
+ 'content' => $this->textinput('customcode'),
562
+ );
563
  $rows[] = array(
564
  'id' => 'trackadsense',
565
  'label' => 'Track AdSense',
611
  'desc' => 'This adds a <code><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setAllowLinker">_setAllowLinker</a></code> call to your tracking code, allowing you to use <code>_link</code> and related functions.',
612
  'content' => $this->checkbox('allowlinker'),
613
  );
614
+ $rows[] = array(
615
+ 'id' => 'allowhash',
616
+ 'label' => 'Set <code>_setAllowHash</code> to false',
617
+ 'desc' => 'This sets <code><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setAllowHash">_setAllowHash</a></code> to false, allowing you to track subdomains etc.',
618
+ 'content' => $this->checkbox('allowhash'),
619
+ );
620
  $rows[] = array(
621
  'id' => 'anonymizeip',
622
  'label' => 'Anonymize IP\'s',
822
  if (substr($options['domain'],0,1) != "." && $options['domain'] != 'none')
823
  $options['domain'] = ".".$options['domain'];
824
  $push[] = "'_setDomainName','".$options['domain']."'";
825
+ }
826
+
827
+ if ( $options['allowhash'] )
828
+ $push[] = "'_setAllowHash',false";
829
 
830
  if ( $options['cv_loggedin'] ) {
831
  $current_user = wp_get_current_user();
946
  echo '</script><script src="'.$url.'" type="text/javascript"></script>'."\n".'<script type="text/javascript">';
947
  }
948
 
949
+ if ( $options['customcode'] && trim( $options['customcode'] ) != '' )
950
+ echo "\t".$options['customcode']."\n";
951
  ?>
952
  _gaq.push(<?php echo $pushstr; ?>);
953
  (function() {
965
 
966
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
967
  })();
 
968
  //]]></script>
969
  <?php
970
  } else if ( $options["uastring"] != "" ) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: joostdevalk
3
  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.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
 
@@ -47,6 +47,8 @@ Other interesting stuff:
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/).
49
 
 
 
50
  == Installation ==
51
 
52
  This section describes how to install the plugin and get it working.
@@ -58,7 +60,23 @@ This section describes how to install the plugin and get it working.
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+.
3
  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.1
7
+ Stable tag: 4.0.10
8
 
9
  Track your WordPress site easily and with lots of metadata: views per author & category, automatic tracking of outbound clicks and pageviews.
10
 
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/).
49
 
50
+ <meta name="google-site-verification" content="JfWAcXeAyBe5IPMBFjYLi8OX5K_XFwz3sjSasjsoULs" />
51
+
52
  == Installation ==
53
 
54
  This section describes how to install the plugin and get it working.
60
 
61
  == Changelog ==
62
 
63
+ = 4.0.10 =
64
+
65
+ * Known issues:
66
+ * Authentication with Google gives errors in quite a few cases. Please use the manual option to add your UA code until we find a way to reliably fix it.
67
+
68
+ * Added functionality:
69
+ * Option to set `_setAllowHash` to false, for proper subdomain tracking and some other uses.
70
+ * Option to add a custom string of code to the tracking, before the push string is sent out.
71
+
72
+ * Documentation fixes:
73
+ * Fixed link for `_setDomainName()`.
74
+ * Fixed some grammatical errors (keep emailing me about those, please!)
75
+ * Removed second comment in source output.
76
+ * Fixed version number output in source.
77
+
78
  = 4.0.9 =
79
+
80
  * Code enhancements:
81
  * Updated Shopp integration to also work with the upcoming Shopp 1.1 and higher.
82
  * Switched from [split](http://php.net/split) to [explode](http://php.net/explode), as split has been deprecated in PHP 5.3+.