Google Analytics for WordPress by MonsterInsights - Version 4.0.2

Version Description

  • Old settings from versions below 4.0 are now properly sanitized and inherited (slaps forehead about simplicity of fix).
  • New features in this release:
    • Link sanitization added: relative links will be rewritten to absolute, so /out/ becomes http://example.com/out/ and is tracked properly.
    • Added a feature to track and label internal links as outbound clicks, for instance /out/ links.
    • Added tracking for mailto: links.
    • Added a filter for text-widgets, all links in those widgets are now tagged too.
    • Added support for _anonymizeIp.
  • Bugs fixed in this release:
    • Made sure all content filters don't run when the current user is ignored because of his user level.
Download this release

Release Info

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

Code changes from version 4.0.1 to 4.0.2

Files changed (2) hide show
  1. googleanalytics.php +128 -37
  2. readme.txt +12 -11
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=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.1
8
  Requires at least: 2.8
9
  Author URI: http://yoast.com/
10
  License: GPL
@@ -109,10 +109,12 @@ if ( ! class_exists( 'GA_Admin' ) ) {
109
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
110
  jQuery('#advancedgasettings').css("display","block");
111
  jQuery('#customvarsettings').css("display","block");
 
112
  jQuery('#toc').css("display","block");
113
  } else {
114
  jQuery('#advancedgasettings').css("display","none");
115
  jQuery('#customvarsettings').css("display","none");
 
116
  jQuery('#toc').css("display","none");
117
  }
118
  }).change();
@@ -168,14 +170,14 @@ if ( ! class_exists( 'GA_Admin' ) ) {
168
  if (!current_user_can('manage_options')) die(__('You cannot edit the Google Analytics for WordPress options.'));
169
  check_admin_referer('analyticspp-config');
170
 
171
- foreach (array('uastring', 'dlextensions', 'domainorurl','position','domain', 'ga_token', 'extraseurl', 'gfsubmiteventpv', 'trackprefix', 'ignore_userlevel') as $option_name) {
172
  if (isset($_POST[$option_name]))
173
  $options[$option_name] = $_POST[$option_name];
174
  else
175
  $options[$option_name] = '';
176
  }
177
 
178
- 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') as $option_name) {
179
  if (isset($_POST[$option_name]) && $_POST[$option_name] != 'off')
180
  $options[$option_name] = true;
181
  else
@@ -506,17 +508,40 @@ if ( ! class_exists( 'GA_Admin' ) ) {
506
  $rows[] = array(
507
  'id' => 'allowanchor',
508
  'label' => 'Use # instead of ? for Campaign tracking',
509
- 'desc' => 'This adds a <a href="http://code.google.com/apis/analytics/docs/gaJSApiCampaignTracking.html#_gat.GA_Tracker_._setAllowAnchor">setAllowAnchor</a> call to your tracking code, and makes RSS link tagging use a # as well.',
510
  'content' => $this->checkbox('allowanchor'),
511
  );
512
  $rows[] = array(
513
  'id' => 'allowlinker',
514
  'label' => 'Add <code>_setAllowLinker</code>',
515
- 'desc' => 'This adds a <a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._setAllowLinker">setAllowLinker</a> call to your tracking code, allowing you to use <code>_link</code> and related functions.',
516
  'content' => $this->checkbox('allowlinker'),
517
  );
 
 
 
 
 
 
 
518
  $this->postbox('advancedgasettings','Advanced Settings',$this->form_table($rows).$this->save_button());
519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
  $modules = array();
521
 
522
  /* if (class_exists('RGForms') && GFCommon::$version >= '1.3.11') {
@@ -677,6 +702,9 @@ if ( ! class_exists( 'GA_Filter' ) ) {
677
  if ( $options['allowlinker'] )
678
  $push[] = "'_setAllowLinker',true";
679
 
 
 
 
680
  if ( isset($options['domain']) && $options['domain'] != "" ) {
681
  // should allow for a 'none' domain too!
682
  if (substr($options['domain'],0,1) != "." && $options['domain'] != 'none')
@@ -821,7 +849,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
821
  */
822
  function spool_adsense() {
823
  $options = get_option('Yoast_Google_Analytics');
824
- if ( $options["uastring"] != "" && (!current_user_can('edit_users') || $options["admintracking"]) && !is_preview() ) {
825
  echo '<script type="text/javascript">'."\n";
826
  echo "\t".'window.google_analytics_uacct = "'.$options["uastring"].'";'."\n";
827
  echo '</script>'."\n";
@@ -846,10 +874,7 @@ if ( ! class_exists( 'GA_Filter' ) ) {
846
  }
847
  return $jsprefix."_gaq.push(".$pushstr.");";
848
  }
849
- /* Create an array which contians:
850
- * "domain" e.g. boakes.org
851
- * "host" e.g. store.boakes.org
852
- */
853
  function ga_get_domain($uri){
854
  $hostPattern = "/^(http:\/\/)?([^\/]+)/i";
855
  $domainPatternUS = "/[^\.\/]+\.[^\.\/]+$/";
@@ -870,18 +895,21 @@ if ( ! class_exists( 'GA_Filter' ) ) {
870
  $options = get_option('Yoast_Google_Analytics');
871
 
872
  // Break out immediately if the link is not an http or https link.
873
- if (strpos($matches[2],"http") !== 0)
874
  $target = false;
875
- else
 
 
876
  $target = GA_Filter::ga_get_domain($matches[3]);
877
-
878
  $trackBit = "";
879
  $extension = substr(strrchr($matches[3], '.'), 1);
880
  $dlextensions = split(",",str_replace('.','',$options['dlextensions']));
881
  if ( $target ) {
882
- if ( in_array($extension, $dlextensions) ) {
883
- $file = $matches[3];
884
- $trackBit = GA_Filter::ga_get_tracking_link('download', $file,'');
 
885
  } else if ( $target["domain"] != $origin["domain"] ){
886
  if ($options['domainorurl'] == "domain") {
887
  $url = $target["host"];
@@ -889,7 +917,18 @@ if ( ! class_exists( 'GA_Filter' ) ) {
889
  $url = $matches[3];
890
  }
891
  $trackBit = GA_Filter::ga_get_tracking_link($category, $url,'');
892
- }
 
 
 
 
 
 
 
 
 
 
 
893
  }
894
  if ($trackBit != "") {
895
  if (preg_match('/onclick=[\'\"](.*?)[\'\"]/i', $matches[4]) > 0) {
@@ -914,7 +953,26 @@ if ( ! class_exists( 'GA_Filter' ) ) {
914
  return GA_Filter::ga_parse_link('outbound-comment',$matches);
915
  }
916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  function the_content($text) {
 
 
 
 
 
918
  if (!is_feed()) {
919
  static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';
920
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_article_link'),$text);
@@ -923,6 +981,11 @@ if ( ! class_exists( 'GA_Filter' ) ) {
923
  }
924
 
925
  function comment_text($text) {
 
 
 
 
 
926
  if (!is_feed()) {
927
  static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
928
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_comment_link'),$text);
@@ -931,11 +994,11 @@ if ( ! class_exists( 'GA_Filter' ) ) {
931
  }
932
 
933
  function comment_author_link($text) {
 
934
  $options = get_option('Yoast_Google_Analytics');
935
-
936
- if (current_user_can('edit_users') && !$options["admintracking"]) {
937
  return $text;
938
- }
939
  static $anchorPattern = '/(.*\s+.*?href\s*=\s*)["\'](.*?)["\'](.*)/';
940
  preg_match($anchorPattern, $text, $matches);
941
  if ($matches[2] == "") return $text;
@@ -953,25 +1016,26 @@ if ( ! class_exists( 'GA_Filter' ) ) {
953
  }
954
 
955
  function bookmarks($bookmarks) {
 
956
  $options = get_option('Yoast_Google_Analytics');
 
 
957
 
958
- if (!is_admin() && (!current_user_can('edit_users') || $options['admintracking'] ) ) {
959
- $i = 0;
960
- while ( $i < count($bookmarks) ) {
961
- $target = GA_Filter::ga_get_domain($bookmarks[$i]->link_url);
962
- $sitedomain = GA_Filter::ga_get_domain(get_bloginfo('url'));
963
- if ($target['host'] == $sitedomain['host']) {
964
- $i++;
965
- continue;
966
- }
967
- if ($options['domainorurl'] == "domain")
968
- $url = $target["host"];
969
- else
970
- $url = $bookmarks[$i]->link_url;
971
- $trackBit = '" onclick="'.GA_Filter::ga_get_tracking_link('outbound-blogroll', $url);
972
- $bookmarks[$i]->link_target .= $trackBit;
973
  $i++;
 
974
  }
 
 
 
 
 
 
 
975
  }
976
  return $bookmarks;
977
  }
@@ -1164,6 +1228,21 @@ function gfform_tag() {
1164
  add_action('wp_footer','gfform_tag',10);
1165
  */
1166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1167
  function yoast_analytics() {
1168
  $options = get_option('Yoast_Google_Analytics');
1169
  if ($options['position'] == 'manual')
@@ -1175,8 +1254,19 @@ function yoast_analytics() {
1175
  $gaf = new GA_Filter();
1176
  $options = get_option('Yoast_Google_Analytics');
1177
 
1178
- if (!is_array($options))
1179
- $ga_admin->set_defaults();
 
 
 
 
 
 
 
 
 
 
 
1180
 
1181
  if ( $options['allowanchor'] ) {
1182
  add_action('init','ga_utm_hashtag_redirect',1);
@@ -1185,6 +1275,7 @@ if ( $options['allowanchor'] ) {
1185
  if ($options['trackoutbound']) {
1186
  // filters alter the existing content
1187
  add_filter('the_content', array('GA_Filter','the_content'), 99);
 
1188
  add_filter('the_excerpt', array('GA_Filter','the_content'), 99);
1189
  add_filter('comment_text', array('GA_Filter','comment_text'), 99);
1190
  add_filter('get_bookmarks', array('GA_Filter','bookmarks'), 99);
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
109
  if ((jQuery('#advancedsettings').attr('checked')) == true) {
110
  jQuery('#advancedgasettings').css("display","block");
111
  jQuery('#customvarsettings').css("display","block");
112
+ jQuery('#internallinktracking').css("display","block");
113
  jQuery('#toc').css("display","block");
114
  } else {
115
  jQuery('#advancedgasettings').css("display","none");
116
  jQuery('#customvarsettings').css("display","none");
117
+ jQuery('#internallinktracking').css("display","none");
118
  jQuery('#toc').css("display","none");
119
  }
120
  }).change();
170
  if (!current_user_can('manage_options')) die(__('You cannot edit the Google Analytics for WordPress options.'));
171
  check_admin_referer('analyticspp-config');
172
 
173
+ foreach (array('uastring', 'dlextensions', 'domainorurl','position','domain', 'ga_token', 'extraseurl', 'gfsubmiteventpv', 'trackprefix', 'ignore_userlevel', 'internallink', 'internallinklabel') as $option_name) {
174
  if (isset($_POST[$option_name]))
175
  $options[$option_name] = $_POST[$option_name];
176
  else
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
508
  $rows[] = array(
509
  'id' => 'allowanchor',
510
  'label' => 'Use # instead of ? for Campaign tracking',
511
+ 'desc' => 'This adds a <code><a href="http://code.google.com/apis/analytics/docs/gaJSApiCampaignTracking.html#_gat.GA_Tracker_._setAllowAnchor">_setAllowAnchor</a></code> call to your tracking code, and makes RSS link tagging use a # as well.',
512
  'content' => $this->checkbox('allowanchor'),
513
  );
514
  $rows[] = array(
515
  'id' => 'allowlinker',
516
  'label' => 'Add <code>_setAllowLinker</code>',
517
+ '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.',
518
  'content' => $this->checkbox('allowlinker'),
519
  );
520
+ $rows[] = array(
521
+ 'id' => 'anonymizeip',
522
+ 'label' => 'Anonymize IP\'s',
523
+ '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.',
524
+ 'content' => $this->checkbox('anonymizeip'),
525
+ );
526
+
527
  $this->postbox('advancedgasettings','Advanced Settings',$this->form_table($rows).$this->save_button());
528
 
529
+ $rows = array();
530
+ $rows[] = array(
531
+ 'id' => 'internallink',
532
+ 'label' => 'Internal links to track as outbound',
533
+ 'desc' => 'If you want to track all internal links that begin with <code>/out/</code>, enter <code>/out/</code> in the box above. If you have multiple prefixes you can separate them with comma\'s: <code>/out/,/recommends/</code>',
534
+ 'content' => $this->textinput('internallink'),
535
+ );
536
+ $rows[] = array(
537
+ 'id' => 'internallinklabel',
538
+ 'label' => 'Label to use',
539
+ '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".',
540
+ 'content' => $this->textinput('internallinklabel'),
541
+ );
542
+
543
+ $this->postbox('internallinktracking','Internal Links to Track as Outbound',$this->form_table($rows).$this->save_button());
544
+
545
  $modules = array();
546
 
547
  /* if (class_exists('RGForms') && GFCommon::$version >= '1.3.11') {
702
  if ( $options['allowlinker'] )
703
  $push[] = "'_setAllowLinker',true";
704
 
705
+ if ( $options['anonymizeip'] )
706
+ $push[] = "'_anonymizeIp'";
707
+
708
  if ( isset($options['domain']) && $options['domain'] != "" ) {
709
  // should allow for a 'none' domain too!
710
  if (substr($options['domain'],0,1) != "." && $options['domain'] != 'none')
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";
874
  }
875
  return $jsprefix."_gaq.push(".$pushstr.");";
876
  }
877
+
 
 
 
878
  function ga_get_domain($uri){
879
  $hostPattern = "/^(http:\/\/)?([^\/]+)/i";
880
  $domainPatternUS = "/[^\.\/]+\.[^\.\/]+$/";
895
  $options = get_option('Yoast_Google_Analytics');
896
 
897
  // Break out immediately if the link is not an http or https link.
898
+ if (strpos($matches[2],"http") !== 0) {
899
  $target = false;
900
+ } else if ((strpos($matches[2],"mailto") === 0)) {
901
+ $target = 'email';
902
+ } else {
903
  $target = GA_Filter::ga_get_domain($matches[3]);
904
+ }
905
  $trackBit = "";
906
  $extension = substr(strrchr($matches[3], '.'), 1);
907
  $dlextensions = split(",",str_replace('.','',$options['dlextensions']));
908
  if ( $target ) {
909
+ if ( $target == 'email' ) {
910
+ $trackBit = GA_Filter::ga_get_tracking_link('mailto', str_replace('mailto:','',$matches[3]),'');
911
+ } else if ( in_array($extension, $dlextensions) ) {
912
+ $trackBit = GA_Filter::ga_get_tracking_link('download', $matches[3],'');
913
  } else if ( $target["domain"] != $origin["domain"] ){
914
  if ($options['domainorurl'] == "domain") {
915
  $url = $target["host"];
917
  $url = $matches[3];
918
  }
919
  $trackBit = GA_Filter::ga_get_tracking_link($category, $url,'');
920
+ } else if ( $target["domain"] == $origin["domain"] && isset($options['internallink']) && $options['internallink'] != '') {
921
+ $url = preg_replace('|'.$origin["host"].'|','',$matches[3]);
922
+ $extintlinks = explode(',',$options['internallink']);
923
+ foreach ($extintlinks as $link) {
924
+ if (preg_match('|^'.trim($link).'|', $url, $match)) {
925
+ $label = $options['internallinklabel'];
926
+ if ($label == '')
927
+ $label = 'int';
928
+ $trackBit = GA_Filter::ga_get_tracking_link($category.'-'.$label, $url,'');
929
+ }
930
+ }
931
+ }
932
  }
933
  if ($trackBit != "") {
934
  if (preg_match('/onclick=[\'\"](.*?)[\'\"]/i', $matches[4]) > 0) {
953
  return GA_Filter::ga_parse_link('outbound-comment',$matches);
954
  }
955
 
956
+ function ga_parse_widget_link($matches){
957
+ return GA_Filter::ga_parse_link('outbound-widget',$matches);
958
+ }
959
+
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);
967
+ return $text;
968
+ }
969
+
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()) {
977
  static $anchorPattern = '/<a (.*?)href=[\'\"](.*?)\/\/([^\'\"]+?)[\'\"](.*?)>(.*?)<\/a>/i';
978
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_article_link'),$text);
981
  }
982
 
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()) {
990
  static $anchorPattern = '/<a (.*?)href="(.*?)\/\/(.*?)"(.*?)>(.*?)<\/a>/i';
991
  $text = preg_replace_callback($anchorPattern,array('GA_Filter','ga_parse_comment_link'),$text);
994
  }
995
 
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*)["\'](.*?)["\'](.*)/';
1003
  preg_match($anchorPattern, $text, $matches);
1004
  if ($matches[2] == "") return $text;
1016
  }
1017
 
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;
1025
+ while ( $i < count($bookmarks) ) {
1026
+ $target = GA_Filter::ga_get_domain($bookmarks[$i]->link_url);
1027
+ $sitedomain = GA_Filter::ga_get_domain(get_bloginfo('url'));
1028
+ if ($target['host'] == $sitedomain['host']) {
 
 
 
 
 
 
 
 
 
 
1029
  $i++;
1030
+ continue;
1031
  }
1032
+ if ($options['domainorurl'] == "domain")
1033
+ $url = $target["host"];
1034
+ else
1035
+ $url = $bookmarks[$i]->link_url;
1036
+ $trackBit = '" onclick="'.GA_Filter::ga_get_tracking_link('outbound-blogroll', $url);
1037
+ $bookmarks[$i]->link_target .= $trackBit;
1038
+ $i++;
1039
  }
1040
  return $bookmarks;
1041
  }
1228
  add_action('wp_footer','gfform_tag',10);
1229
  */
1230
 
1231
+ function yoast_sanitize_relative_links($content) {
1232
+ $blogurl = get_bloginfo('url');
1233
+ if (substr($blogurl, -1) == "/") {
1234
+ $blogurl = substr($blogurl, 0, strlen($blogurl));
1235
+ }
1236
+ $content = preg_replace("/<a([^>]*) href=('|\")\/([^\"']*)('|\")/", "<a\${1} href=\"" .$blogurl ."/" ."\${3}\"", $content);
1237
+
1238
+ if (is_singular()) {
1239
+ $content = preg_replace("/<a([^>]*) href=('|\")#([^\"']*)('|\")/", "<a\${1} href=\"" .get_permalink()."#" ."\${3}\"", $content);
1240
+ }
1241
+ return $content;
1242
+ }
1243
+ add_filter('the_content', 'yoast_sanitize_relative_links', 98);
1244
+ add_filter('widget_text', 'yoast_sanitize_relative_links', 98);
1245
+
1246
  function yoast_analytics() {
1247
  $options = get_option('Yoast_Google_Analytics');
1248
  if ($options['position'] == 'manual')
1254
  $gaf = new GA_Filter();
1255
  $options = get_option('Yoast_Google_Analytics');
1256
 
1257
+ if (!is_array($options)) {
1258
+ $options = get_option('GoogleAnalyticsPP');
1259
+ if (!is_array($options)) {
1260
+ $ga_admin->set_defaults();
1261
+ } else {
1262
+ delete_option('GoogleAnalyticsPP');
1263
+ if ($options['admintracking']) {
1264
+ $options["ignore_userlevel"] = '8';
1265
+ unset($options['admintracking']);
1266
+ }
1267
+ update_option('Yoast_Google_Analytics', $options);
1268
+ }
1269
+ }
1270
 
1271
  if ( $options['allowanchor'] ) {
1272
  add_action('init','ga_utm_hashtag_redirect',1);
1275
  if ($options['trackoutbound']) {
1276
  // filters alter the existing content
1277
  add_filter('the_content', array('GA_Filter','the_content'), 99);
1278
+ add_filter('widget_text', array('GA_Filter','widget_content'), 99);
1279
  add_filter('the_excerpt', array('GA_Filter','the_content'), 99);
1280
  add_filter('comment_text', array('GA_Filter','comment_text'), 99);
1281
  add_filter('get_bookmarks', array('GA_Filter','bookmarks'), 99);
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.1
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
 
@@ -14,8 +14,6 @@ The Google Analytics for WordPress plugin allows you to track your blog easily.
14
 
15
  For the full list of features, check out the [Google Analytics for WordPress](http://yoast.com/wordpress/google-analytics/) homepage.
16
 
17
- NOTE WHEN UPGRADING TO VERSION 4.0: you'll have to reconfigure the plugin so it can fully support all the new features!
18
-
19
  * Other [Wordpress plugins](http://yoast.com/wordpress/) by the same author.
20
  * Want to increase traffic to your WordPress blog? Check out the [WordPress SEO](http://yoast.com/articles/wordpress-seo/) Guide!
21
  * 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!
@@ -31,6 +29,17 @@ This section describes how to install the plugin and get it working.
31
 
32
  == Changelog ==
33
 
 
 
 
 
 
 
 
 
 
 
 
34
  = 4.0.1 =
35
  * Fix for when you have only 1 site in a specific Analytics profile.
36
 
@@ -162,18 +171,10 @@ For some more info, see the screenshot under Screenshots.
162
 
163
  No. You can not. It will break tracking.
164
 
165
- = How do I check the image search stats and keywords after installing this plugin? =
166
-
167
- Check out this <a href="http://yoast.com/wordpress/google-analytics/how-to-check-your-image-search-stats-and-keywords/">tutorial on checking your image search stats and keywords</a>.
168
-
169
  = How do I check my outbound link and download stats? =
170
 
171
  Check out this <a href="http://yoast.com/wordpress/google-analytics/checking-your-outbound-click-stats/">tutorial on checking your outbound click stats</a>.
172
 
173
- = I want the image search keywords in one big overview... =
174
-
175
- Create a <a href="http://yoast.com/wordpress/google-analytics/creating-a-google-analytics-filter-for-image-search/">Google Analytics filter for image search</a>.
176
-
177
  == Screenshots ==
178
 
179
  1. Screenshot of the configuration panel for this plugin.
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
 
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!
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:
35
+ * Link sanitization added: relative links will be rewritten to absolute, so /out/ becomes http://example.com/out/ and is tracked properly.
36
+ * Added a feature to track and label internal links as outbound clicks, for instance /out/ links.
37
+ * Added tracking for mailto: links.
38
+ * Added a filter for text-widgets, all links in those widgets are now tagged too.
39
+ * Added support for [_anonymizeIp](http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp).
40
+ * Bugs fixed in this release:
41
+ * Made sure all content filters don't run when the current user is ignored because of his user level.
42
+
43
  = 4.0.1 =
44
  * Fix for when you have only 1 site in a specific Analytics profile.
45
 
171
 
172
  No. You can not. It will break tracking.
173
 
 
 
 
 
174
  = How do I check my outbound link and download stats? =
175
 
176
  Check out this <a href="http://yoast.com/wordpress/google-analytics/checking-your-outbound-click-stats/">tutorial on checking your outbound click stats</a>.
177
 
 
 
 
 
178
  == Screenshots ==
179
 
180
  1. Screenshot of the configuration panel for this plugin.