Google Analyticator - Version 4.1.1

Version Description

Download this release

Release Info

Developer cavemonkey50
Plugin Icon 128x128 Google Analyticator
Version 4.1.1
Comparing to
See all releases

Code changes from version 4.1 to 4.1.1

class.analytics.stats.php CHANGED
@@ -86,6 +86,10 @@ class GoogleAnalyticsStats
86
  # Request the list of accounts
87
  $response = $this->curl($this->baseFeed . '/accounts/default', false, '0');
88
 
 
 
 
 
89
  # Parse the XML using SimplePie
90
  $simplePie = new SimplePie();
91
  $simplePie->set_raw_data($response);
86
  # Request the list of accounts
87
  $response = $this->curl($this->baseFeed . '/accounts/default', false, '0');
88
 
89
+ # Check if the response received exists, else stop processing now
90
+ if ( $response == '' )
91
+ return array();
92
+
93
  # Parse the XML using SimplePie
94
  $simplePie = new SimplePie();
95
  $simplePie->set_raw_data($response);
google-analyticator.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
- * Version: 4.1
5
  * Plugin URI: http://plugins.spiralwebconsulting.com/analyticator.html
6
  * Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Spiral Web Consulting
@@ -444,7 +444,7 @@ function ga_options_page() {
444
  echo "id='".key_ga_adsense."' ";
445
  echo "value='".get_option(key_ga_adsense)."' />\n";
446
  ?>
447
- <p style="margin: 5px 10px;" class="setting-description">Enter your Google Adsense ID assigned by Google Analytics in this box. This enables Analytics tracking of Adsense information if your Adsense and Analytics accounts are linked. Note: It is highly recommended to not have the Google Analytics tracking code in the footer with this option enabled. Google may be unable to track your Adsense data.</p>
448
  </td>
449
  </tr>
450
  <tr>
@@ -515,14 +515,37 @@ function ga_options_page() {
515
  }
516
 
517
  // Add the script
 
518
  if (get_option(key_ga_footer) == ga_enabled) {
 
 
519
  add_action('wp_footer', 'add_google_analytics');
520
  } else {
521
  add_action('wp_head', 'add_google_analytics');
522
  }
523
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  // The guts of the Google Analytics script
525
  function add_google_analytics() {
 
 
526
  $uid = stripslashes(get_option(key_ga_uid));
527
  $extra = stripslashes(get_option(key_ga_extra));
528
  $extra_after = stripslashes(get_option(key_ga_extra_after));
@@ -536,7 +559,7 @@ function add_google_analytics() {
536
 
537
  echo "<!-- Google Analytics Tracking by Google Analyticator: http://plugins.spiralwebconsulting.com/analyticator.html -->\n";
538
  # Google Adsense data if enabled
539
- if ( get_option(key_ga_adsense) != '' )
540
  echo ' <script type="text/javascript">window.google_analytics_uacct = "' . get_option(key_ga_adsense) . "\";</script>\n\n";
541
 
542
  // Pick the HTTP connection
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
+ * Version: 4.1.1
5
  * Plugin URI: http://plugins.spiralwebconsulting.com/analyticator.html
6
  * Description: Adds the necessary JavaScript code to enable <a href="http://www.google.com/analytics/">Google's Analytics</a>. After enabling this plugin visit <a href="options-general.php?page=google-analyticator.php">the settings page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Spiral Web Consulting
444
  echo "id='".key_ga_adsense."' ";
445
  echo "value='".get_option(key_ga_adsense)."' />\n";
446
  ?>
447
+ <p style="margin: 5px 10px;" class="setting-description">Enter your Google Adsense ID assigned by Google Analytics in this box. This enables Analytics tracking of Adsense information if your Adsense and Analytics accounts are linked. Note: Google recommends the Analytics tracking code is placed in the header with this option enabled, however, a fix is included in this plugin. To follow the official specs, do not enable footer tracking.</p>
448
  </td>
449
  </tr>
450
  <tr>
515
  }
516
 
517
  // Add the script
518
+ $ga_in_footer = false;
519
  if (get_option(key_ga_footer) == ga_enabled) {
520
+ $ga_in_footer = true;
521
+ add_action('wp_head', 'add_ga_adsense');
522
  add_action('wp_footer', 'add_google_analytics');
523
  } else {
524
  add_action('wp_head', 'add_google_analytics');
525
  }
526
 
527
+ /**
528
+ * Adds the Analytics Adsense tracking code to the header if the main Analytics tracking code is in the footer.
529
+ * Idea and code for Adsense tracking with main code in footer props William Charles Nickerson on May 16, 2009.
530
+ **/
531
+ function add_ga_adsense() {
532
+ $uid = stripslashes(get_option(key_ga_uid));
533
+ // If GA is enabled and has a valid key
534
+ if ( (get_option(key_ga_status) != ga_disabled ) && ( $uid != "XX-XXXXX-X" )) {
535
+ // Display page tracking if user is not an admin
536
+ if ( ( get_option(key_ga_admin) == ga_enabled || !current_user_can('level_' . get_option(key_ga_admin_level)) ) && get_option(key_ga_admin_disable) == 'remove' || get_option(key_ga_admin_disable) != 'remove' ) {
537
+ echo "<!-- Google Analytics Tracking by Google Analyticator: http://plugins.spiralwebconsulting.com/analyticator.html -->\n";
538
+ if ( get_option(key_ga_adsense) != '' ) {
539
+ echo ' <script type="text/javascript">window.google_analytics_uacct = "' . get_option(key_ga_adsense) . "\";</script>\n\n";
540
+ }
541
+ }
542
+ }
543
+ }
544
+
545
  // The guts of the Google Analytics script
546
  function add_google_analytics() {
547
+ global $ga_in_footer;
548
+
549
  $uid = stripslashes(get_option(key_ga_uid));
550
  $extra = stripslashes(get_option(key_ga_extra));
551
  $extra_after = stripslashes(get_option(key_ga_extra_after));
559
 
560
  echo "<!-- Google Analytics Tracking by Google Analyticator: http://plugins.spiralwebconsulting.com/analyticator.html -->\n";
561
  # Google Adsense data if enabled
562
+ if ( get_option(key_ga_adsense) != '' && !$ga_in_footer )
563
  echo ' <script type="text/javascript">window.google_analytics_uacct = "' . get_option(key_ga_adsense) . "\";</script>\n\n";
564
 
565
  // Pick the HTTP connection
google-analytics-stats.php CHANGED
@@ -108,14 +108,21 @@ class GoogleStatsWidget
108
  $line1 = htmlspecialchars($options['line1']);
109
  $line2 = htmlspecialchars($options['line2']);
110
 
111
- # Get the class for interacting with the Google Analytics
112
- require_once('class.analytics.stats.php');
113
 
114
- # Create a new Gdata call
115
- $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
116
 
117
- # Get a list of accounts
118
- $accounts = $stats->getAnalyticsAccounts();
 
 
 
 
 
 
 
 
119
 
120
  # Output the options
121
  echo '<p style="text-align:right;"><label for="google_stats_title">' . __('Title:') . ' <input style="width: 250px;" id="google_stats_title" name="google_stats_title" type="text" value="' . $title . '" /></label></p>';
@@ -204,7 +211,7 @@ class GoogleStatsWidget
204
  echo '</tr></table>';
205
 
206
  // The following is used to displayed the "Powered By Google Anayltics" text.
207
- echo '<div style="font-size:9px;color:#666666;margin-top:0px;font-family:Verdana;">Powered By <a href="http://google.com/analytics/" alt="Google Analytics" style="text-decoration:none;"><img src="' . get_option('home') . '/wp-content/plugins/google-analyticator/ga_logo.png" alt="Google Analytics" style="border:0px;position:relative;top:4px;" /></a></div></div>';
208
  }
209
 
210
  /**
108
  $line1 = htmlspecialchars($options['line1']);
109
  $line2 = htmlspecialchars($options['line2']);
110
 
111
+ $accounts = array();
 
112
 
113
+ # Check if a username has been set
114
+ if ( get_option('google_stats_user') != '' ) {
115
 
116
+ # Get the class for interacting with the Google Analytics
117
+ require_once('class.analytics.stats.php');
118
+
119
+ # Create a new Gdata call
120
+ $stats = new GoogleAnalyticsStats(stripslashes(get_option('google_stats_user')), stripslashes(get_option('google_stats_password')), true);
121
+
122
+ # Get a list of accounts
123
+ $accounts = $stats->getAnalyticsAccounts();
124
+
125
+ }
126
 
127
  # Output the options
128
  echo '<p style="text-align:right;"><label for="google_stats_title">' . __('Title:') . ' <input style="width: 250px;" id="google_stats_title" name="google_stats_title" type="text" value="' . $title . '" /></label></p>';
211
  echo '</tr></table>';
212
 
213
  // The following is used to displayed the "Powered By Google Anayltics" text.
214
+ echo '<div style="font-size:9px;color:#666666;margin-top:0px;font-family:Verdana;">Powered By <a href="http://google.com/analytics/" alt="Google Analytics" style="text-decoration:none;"><img src="' . plugins_url('/google-analyticator/ga_logo.png') . '" alt="Google Analytics" style="border:0px;position:relative;top:4px;" /></a></div></div>';
215
  }
216
 
217
  /**
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: cavemonkey50, spiralwebconsulting
3
  Tags: stats, google, analytics, tracking
4
  Requires at least: 2.7
5
- Tested up to: 2.7
6
- Stable tag: 4.1
7
 
8
  Adds the necessary JavaScript code to enable Google Analytics.
9
 
2
  Contributors: cavemonkey50, spiralwebconsulting
3
  Tags: stats, google, analytics, tracking
4
  Requires at least: 2.7
5
+ Tested up to: 2.8
6
+ Stable tag: 4.1.1
7
 
8
  Adds the necessary JavaScript code to enable Google Analytics.
9