Google Analyticator - Version 1.41

Version Description

Download this release

Release Info

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

Code changes from version 1.4 to 1.41

Files changed (2) hide show
  1. google-analyticator.php +38 -2
  2. readme.txt +3 -1
google-analyticator.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
- * Version: 1.4
5
  * Plugin URI: http://cavemonkey50.com/code/google-analyticator/
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 options page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Ronald Heft, Jr.
@@ -19,6 +19,7 @@ define("key_ga_admin", "ga_admin_status", true);
19
  define("key_ga_extra", "ga_extra", true);
20
  define("key_ga_outbound", "ga_outbound", true);
21
  define("key_ga_downloads", "ga_downloads", true);
 
22
 
23
  define("ga_uid_default", "XX-XXXXX-X", true);
24
  define("ga_status_default", ga_disabled, true);
@@ -26,6 +27,7 @@ define("ga_admin_default", ga_enabled, true);
26
  define("ga_extra_default", "", true);
27
  define("ga_outbound_default", ga_enabled, true);
28
  define("ga_downloads_default", "", true);
 
29
 
30
  // Create the default key and status
31
  add_option(key_ga_status, ga_status_default, 'If Google Analytics logging in turned on or off.');
@@ -34,6 +36,7 @@ add_option(key_ga_admin, ga_admin_default, 'If WordPress admins are counted in G
34
  add_option(key_ga_extra, ga_extra_default, 'Addition Google Analytics tracking options');
35
  add_option(key_ga_outbound, ga_outbound_default, 'Add tracking of outbound links');
36
  add_option(key_ga_downloads, ga_downloads_default, 'Download extensions to track with Google Analyticator');
 
37
 
38
  // Create a option page for settings
39
  add_action('admin_menu', 'add_ga_option_page');
@@ -80,6 +83,12 @@ function ga_options_page() {
80
  // Update the download tracking code
81
  $ga_downloads = $_POST[key_ga_downloads];
82
  update_option(key_ga_downloads, $ga_downloads);
 
 
 
 
 
 
83
 
84
  // Give an updated message
85
  echo "<div class='updated'><p><strong>Google Analyticator options updated</strong></p></div>";
@@ -191,6 +200,29 @@ function ga_options_page() {
191
  <p style="margin: 5px 10px;">Disabling this option will turn off the tracking of outbound links. It's recommended not to disable this option unless you're a privacy advocate (now why would you be using Google Analytics in the first place?) or it's causing some kind of weird issue.</p>
192
  </td>
193
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  <tr>
195
  <th valign="top" style="padding-top: 10px;">
196
  <label for="<?php echo key_ga_extra; ?>">Additional tracking code:</label>
@@ -231,7 +263,11 @@ function ga_options_page() {
231
  }
232
 
233
  // Add the script
234
- add_action('wp_head', 'add_google_analytics');
 
 
 
 
235
 
236
  // Add the ougoing links script
237
  function outgoing_links() {
1
  <?php
2
  /*
3
  * Plugin Name: Google Analyticator
4
+ * Version: 1.41
5
  * Plugin URI: http://cavemonkey50.com/code/google-analyticator/
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 options page</a> and enter your Google Analytics' UID and enable logging.
7
  * Author: Ronald Heft, Jr.
19
  define("key_ga_extra", "ga_extra", true);
20
  define("key_ga_outbound", "ga_outbound", true);
21
  define("key_ga_downloads", "ga_downloads", true);
22
+ define("key_ga_footer", "ga_footer", true);
23
 
24
  define("ga_uid_default", "XX-XXXXX-X", true);
25
  define("ga_status_default", ga_disabled, true);
27
  define("ga_extra_default", "", true);
28
  define("ga_outbound_default", ga_enabled, true);
29
  define("ga_downloads_default", "", true);
30
+ define("ga_footer_default", ga_disabled, true);
31
 
32
  // Create the default key and status
33
  add_option(key_ga_status, ga_status_default, 'If Google Analytics logging in turned on or off.');
36
  add_option(key_ga_extra, ga_extra_default, 'Addition Google Analytics tracking options');
37
  add_option(key_ga_outbound, ga_outbound_default, 'Add tracking of outbound links');
38
  add_option(key_ga_downloads, ga_downloads_default, 'Download extensions to track with Google Analyticator');
39
+ add_option(key_ga_footer, ga_footer_default, 'If Google Analyticator is outputting in the footer');
40
 
41
  // Create a option page for settings
42
  add_action('admin_menu', 'add_ga_option_page');
83
  // Update the download tracking code
84
  $ga_downloads = $_POST[key_ga_downloads];
85
  update_option(key_ga_downloads, $ga_downloads);
86
+
87
+ // Update the footer
88
+ $ga_footer = $_POST[key_ga_footer];
89
+ if (($ga_footer != ga_enabled) && ($ga_footer != ga_disabled))
90
+ $ga_footer = ga_footer_default;
91
+ update_option(key_ga_footer, $ga_footer);
92
 
93
  // Give an updated message
94
  echo "<div class='updated'><p><strong>Google Analyticator options updated</strong></p></div>";
200
  <p style="margin: 5px 10px;">Disabling this option will turn off the tracking of outbound links. It's recommended not to disable this option unless you're a privacy advocate (now why would you be using Google Analytics in the first place?) or it's causing some kind of weird issue.</p>
201
  </td>
202
  </tr>
203
+ <tr>
204
+ <th width="30%" valign="top" style="padding-top: 10px;">
205
+ <label for="<?php echo key_ga_footer ?>">Footer tracking code:</label>
206
+ </th>
207
+ <td>
208
+ <?php
209
+ echo "<select name='".key_ga_footer."' id='".key_ga_footer."'>\n";
210
+
211
+ echo "<option value='".ga_enabled."'";
212
+ if(get_option(key_ga_footer) == ga_enabled)
213
+ echo " selected='selected'";
214
+ echo ">Enabled</option>\n";
215
+
216
+ echo "<option value='".ga_disabled."'";
217
+ if(get_option(key_ga_footer) == ga_disabled)
218
+ echo" selected='selected'";
219
+ echo ">Disabled</option>\n";
220
+
221
+ echo "</select>\n";
222
+ ?>
223
+ <p style="margin: 5px 10px;">Enabling this option will insert the Google Analytics tracking code in your site's footer instead of your header. This will speed up your page loading if turned on. Not all themes support code in the footer, so if you turn this option on, be sure to check the Analytics code is still displayed on your site.</p>
224
+ </td>
225
+ </tr>
226
  <tr>
227
  <th valign="top" style="padding-top: 10px;">
228
  <label for="<?php echo key_ga_extra; ?>">Additional tracking code:</label>
263
  }
264
 
265
  // Add the script
266
+ if (get_option(key_ga_footer) == ga_enabled) {
267
+ add_action('wp_footer', 'add_google_analytics');
268
+ } else {
269
+ add_action('wp_head', 'add_google_analytics');
270
+ }
271
 
272
  // Add the ougoing links script
273
  function outgoing_links() {
readme.txt CHANGED
@@ -11,6 +11,8 @@ In your WordPress administration page go to Options > Google Analytics. From the
11
  Once you save your settings, the JavaScript code should now be appearing on all of your WordPress pages.
12
 
13
  == Version History ==
 
 
14
  1.4 - Adds download tracking.
15
 
16
  1.31 - Fixes a small bug with backslashes in the additional tracking code box.
@@ -28,5 +30,5 @@ Once you save your settings, the JavaScript code should now be appearing on all
28
  1.0 - Initial Release
29
 
30
  == Credits ==
31
- Copyright (c) 2005 Ronald Heft, Jr. (ron@cavemonkey50.com)
32
  Released under the terms of the GPL
11
  Once you save your settings, the JavaScript code should now be appearing on all of your WordPress pages.
12
 
13
  == Version History ==
14
+ 1.41 - Adds the option to insert tracking code in the footer instead of the header.
15
+
16
  1.4 - Adds download tracking.
17
 
18
  1.31 - Fixes a small bug with backslashes in the additional tracking code box.
30
  1.0 - Initial Release
31
 
32
  == Credits ==
33
+ Copyright (c) 2006 Ronald Heft, Jr. (ron@cavemonkey50.com)
34
  Released under the terms of the GPL