Version Description
Download this release
Release Info
Developer | cavemonkey50 |
Plugin | Google Analyticator |
Version | 2.21 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.21
- google-analyticator.php +34 -21
- readme.txt +5 -2
google-analyticator.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Plugin Name: Google Analyticator
|
4 |
-
* Version: 2.
|
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.
|
@@ -36,7 +36,7 @@ define("ga_footer_default", ga_disabled, true);
|
|
36 |
define("ga_specify_http_default", "auto", true);
|
37 |
|
38 |
// Create the default key and status
|
39 |
-
add_option(key_ga_status, ga_status_default, 'If Google Analytics logging in turned on or off.');
|
40 |
add_option(key_ga_uid, ga_uid_default, 'Your Google Analytics UID.');
|
41 |
add_option(key_ga_admin, ga_admin_default, 'If WordPress admins are counted in Google Analytics.');
|
42 |
add_option(key_ga_admin_level, ga_admin_level_default, 'The level to consider a user a WordPress admin.');
|
@@ -45,11 +45,29 @@ add_option(key_ga_extra_after, ga_extra_after_default, 'Addition Google Analytic
|
|
45 |
add_option(key_ga_outbound, ga_outbound_default, 'Add tracking of outbound links');
|
46 |
add_option(key_ga_downloads, ga_downloads_default, 'Download extensions to track with Google Analyticator');
|
47 |
add_option(key_ga_footer, ga_footer_default, 'If Google Analyticator is outputting in the footer');
|
48 |
-
add_option(key_ga_specify_http, ga_specify_http_default, 'Automatically detect the http/https settings')
|
49 |
|
50 |
// Create a option page for settings
|
|
|
51 |
add_action('admin_menu', 'add_ga_option_page');
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// Initialize outbound link tracking
|
54 |
add_action('init', 'ga_outgoing_links');
|
55 |
|
@@ -59,15 +77,10 @@ function add_ga_option_page() {
|
|
59 |
add_options_page('Google Analyticator Options', 'Google Analytics', 8, basename(__FILE__), 'ga_options_page');
|
60 |
}
|
61 |
|
62 |
-
// wp_nonce
|
63 |
-
function ga_nonce_field() {
|
64 |
-
echo "<input type='hidden' name='ga-nonce-key' value='" . wp_create_nonce('google-analyticator') . "' />";
|
65 |
-
}
|
66 |
-
|
67 |
function ga_options_page() {
|
68 |
// If we are a postback, store the options
|
69 |
-
|
70 |
-
if ( wp_verify_nonce($_POST['ga-nonce-key'], 'google-analyticator') ) {
|
71 |
|
72 |
// Update the status
|
73 |
$ga_status = $_POST[key_ga_status];
|
@@ -125,7 +138,7 @@ function ga_options_page() {
|
|
125 |
|
126 |
// Give an updated message
|
127 |
echo "<div class='updated fade'><p><strong>Google Analyticator settings saved.</strong></p></div>";
|
128 |
-
}
|
129 |
}
|
130 |
|
131 |
// Output the options page
|
@@ -133,8 +146,7 @@ function ga_options_page() {
|
|
133 |
|
134 |
<div class="wrap">
|
135 |
<form method="post" action="options-general.php?page=google-analyticator.php">
|
136 |
-
|
137 |
-
<h2>Google Analyticator Options</h2>
|
138 |
<h3>Basic Options</h3>
|
139 |
<?php if (get_option(key_ga_status) == ga_disabled) { ?>
|
140 |
<div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
|
@@ -180,7 +192,7 @@ function ga_options_page() {
|
|
180 |
echo "id='".key_ga_uid."' ";
|
181 |
echo "value='".get_option(key_ga_uid)."' />\n";
|
182 |
?>
|
183 |
-
<p style="margin: 5px 10px;">Enter your Google Analytics' UID in this box. The UID is needed for Google Analytics to log your website stats. Your UID can be found by looking in the JavaScript Google Analytics gives you to put on your page. Look for your UID in between <strong>_uacct = "UA-11111-1";</strong> in the JavaScript. In this example you would put <strong>UA-11111-1</strong> in the UID box.</p>
|
184 |
</td>
|
185 |
</tr>
|
186 |
</table>
|
@@ -206,7 +218,7 @@ function ga_options_page() {
|
|
206 |
|
207 |
echo "</select>\n";
|
208 |
?>
|
209 |
-
<p style="margin: 5px 10px;">Disabling this option will prevent all logged in WordPress admins from showing up on your Google Analytics reports. A WordPress admin is defined as a user with a level <?php
|
210 |
echo "<input type='text' size='2' ";
|
211 |
echo "name='".key_ga_admin_level."' ";
|
212 |
echo "id='".key_ga_admin_level."' ";
|
@@ -257,7 +269,7 @@ function ga_options_page() {
|
|
257 |
|
258 |
echo "</select>\n";
|
259 |
?>
|
260 |
-
<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>
|
261 |
</td>
|
262 |
</tr>
|
263 |
<tr>
|
@@ -280,7 +292,7 @@ function ga_options_page() {
|
|
280 |
|
281 |
echo "</select>\n";
|
282 |
?>
|
283 |
-
<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>
|
284 |
</td>
|
285 |
</tr>
|
286 |
<tr>
|
@@ -294,7 +306,7 @@ function ga_options_page() {
|
|
294 |
echo "id='".key_ga_downloads."' ";
|
295 |
echo "value='".stripslashes(get_option(key_ga_downloads))."' />\n";
|
296 |
?>
|
297 |
-
<p style="margin: 5px 10px;">Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter <strong>mp3,pdf</strong>. <em>Outbound link tracking must be enabled for downloads to be tracked.</em></p>
|
298 |
</td>
|
299 |
</tr>
|
300 |
<tr>
|
@@ -308,7 +320,7 @@ function ga_options_page() {
|
|
308 |
echo "id='".key_ga_extra."'>";
|
309 |
echo stripslashes(get_option(key_ga_extra))."</textarea>\n";
|
310 |
?>
|
311 |
-
<p style="margin: 5px 10px;">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>before</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
|
312 |
</td>
|
313 |
</tr>
|
314 |
<tr>
|
@@ -322,7 +334,7 @@ function ga_options_page() {
|
|
322 |
echo "id='".key_ga_extra_after."'>";
|
323 |
echo stripslashes(get_option(key_ga_extra_after))."</textarea>\n";
|
324 |
?>
|
325 |
-
<p style="margin: 5px 10px;">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>after</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
|
326 |
</td>
|
327 |
</tr>
|
328 |
<tr>
|
@@ -350,11 +362,12 @@ function ga_options_page() {
|
|
350 |
|
351 |
echo "</select>\n";
|
352 |
?>
|
353 |
-
<p style="margin: 5px 10px;">Explicitly set the type of HTTP connection your website uses. Setting this option instead of relying on the auto detect may resolve the _gat is undefined error message.</p>
|
354 |
</td>
|
355 |
</tr>
|
356 |
</table>
|
357 |
<p class="submit">
|
|
|
358 |
<input type='submit' name='info_update' value='Save Changes' />
|
359 |
</p>
|
360 |
</div>
|
1 |
<?php
|
2 |
/*
|
3 |
* Plugin Name: Google Analyticator
|
4 |
+
* Version: 2.21
|
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.
|
36 |
define("ga_specify_http_default", "auto", true);
|
37 |
|
38 |
// Create the default key and status
|
39 |
+
/*add_option(key_ga_status, ga_status_default, 'If Google Analytics logging in turned on or off.');
|
40 |
add_option(key_ga_uid, ga_uid_default, 'Your Google Analytics UID.');
|
41 |
add_option(key_ga_admin, ga_admin_default, 'If WordPress admins are counted in Google Analytics.');
|
42 |
add_option(key_ga_admin_level, ga_admin_level_default, 'The level to consider a user a WordPress admin.');
|
45 |
add_option(key_ga_outbound, ga_outbound_default, 'Add tracking of outbound links');
|
46 |
add_option(key_ga_downloads, ga_downloads_default, 'Download extensions to track with Google Analyticator');
|
47 |
add_option(key_ga_footer, ga_footer_default, 'If Google Analyticator is outputting in the footer');
|
48 |
+
add_option(key_ga_specify_http, ga_specify_http_default, 'Automatically detect the http/https settings');*/
|
49 |
|
50 |
// Create a option page for settings
|
51 |
+
add_action('admin_init', 'ga_admin_init');
|
52 |
add_action('admin_menu', 'add_ga_option_page');
|
53 |
|
54 |
+
// Initialize the options
|
55 |
+
function ga_admin_init() {
|
56 |
+
// Register out options so WordPress knows about them
|
57 |
+
if ( function_exists('register_setting') ) {
|
58 |
+
register_setting('google-analyticator', key_ga_status, '');
|
59 |
+
register_setting('google-analyticator', key_ga_uid, '');
|
60 |
+
register_setting('google-analyticator', key_ga_admin, '');
|
61 |
+
register_setting('google-analyticator', key_ga_admin_level, '');
|
62 |
+
register_setting('google-analyticator', key_ga_extra, '');
|
63 |
+
register_setting('google-analyticator', key_ga_extra_after, '');
|
64 |
+
register_setting('google-analyticator', key_ga_outbound, '');
|
65 |
+
register_setting('google-analyticator', key_ga_downloads, '');
|
66 |
+
register_setting('google-analyticator', key_ga_footer, '');
|
67 |
+
register_setting('google-analyticator', key_ga_specify_http, '');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
// Initialize outbound link tracking
|
72 |
add_action('init', 'ga_outgoing_links');
|
73 |
|
77 |
add_options_page('Google Analyticator Options', 'Google Analytics', 8, basename(__FILE__), 'ga_options_page');
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
80 |
function ga_options_page() {
|
81 |
// If we are a postback, store the options
|
82 |
+
if (isset($_POST['info_update'])) {
|
83 |
+
// if ( wp_verify_nonce($_POST['ga-nonce-key'], 'google-analyticator') ) {
|
84 |
|
85 |
// Update the status
|
86 |
$ga_status = $_POST[key_ga_status];
|
138 |
|
139 |
// Give an updated message
|
140 |
echo "<div class='updated fade'><p><strong>Google Analyticator settings saved.</strong></p></div>";
|
141 |
+
// }
|
142 |
}
|
143 |
|
144 |
// Output the options page
|
146 |
|
147 |
<div class="wrap">
|
148 |
<form method="post" action="options-general.php?page=google-analyticator.php">
|
149 |
+
<h2>Google Analyticator Settings</h2>
|
|
|
150 |
<h3>Basic Options</h3>
|
151 |
<?php if (get_option(key_ga_status) == ga_disabled) { ?>
|
152 |
<div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
|
192 |
echo "id='".key_ga_uid."' ";
|
193 |
echo "value='".get_option(key_ga_uid)."' />\n";
|
194 |
?>
|
195 |
+
<p style="margin: 5px 10px;" class="setting-description">Enter your Google Analytics' UID in this box. The UID is needed for Google Analytics to log your website stats. Your UID can be found by looking in the JavaScript Google Analytics gives you to put on your page. Look for your UID in between <strong>_uacct = "UA-11111-1";</strong> in the JavaScript. In this example you would put <strong>UA-11111-1</strong> in the UID box.</p>
|
196 |
</td>
|
197 |
</tr>
|
198 |
</table>
|
218 |
|
219 |
echo "</select>\n";
|
220 |
?>
|
221 |
+
<p style="margin: 5px 10px;" class="setting-description">Disabling this option will prevent all logged in WordPress admins from showing up on your Google Analytics reports. A WordPress admin is defined as a user with a level <?php
|
222 |
echo "<input type='text' size='2' ";
|
223 |
echo "name='".key_ga_admin_level."' ";
|
224 |
echo "id='".key_ga_admin_level."' ";
|
269 |
|
270 |
echo "</select>\n";
|
271 |
?>
|
272 |
+
<p style="margin: 5px 10px;" class="setting-description">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>
|
273 |
</td>
|
274 |
</tr>
|
275 |
<tr>
|
292 |
|
293 |
echo "</select>\n";
|
294 |
?>
|
295 |
+
<p style="margin: 5px 10px;" class="setting-description">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>
|
296 |
</td>
|
297 |
</tr>
|
298 |
<tr>
|
306 |
echo "id='".key_ga_downloads."' ";
|
307 |
echo "value='".stripslashes(get_option(key_ga_downloads))."' />\n";
|
308 |
?>
|
309 |
+
<p style="margin: 5px 10px;" class="setting-description">Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter <strong>mp3,pdf</strong>. <em>Outbound link tracking must be enabled for downloads to be tracked.</em></p>
|
310 |
</td>
|
311 |
</tr>
|
312 |
<tr>
|
320 |
echo "id='".key_ga_extra."'>";
|
321 |
echo stripslashes(get_option(key_ga_extra))."</textarea>\n";
|
322 |
?>
|
323 |
+
<p style="margin: 5px 10px;" class="setting-description">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>before</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
|
324 |
</td>
|
325 |
</tr>
|
326 |
<tr>
|
334 |
echo "id='".key_ga_extra_after."'>";
|
335 |
echo stripslashes(get_option(key_ga_extra_after))."</textarea>\n";
|
336 |
?>
|
337 |
+
<p style="margin: 5px 10px;" class="setting-description">Enter any additional lines of tracking code that you would like to include in the Google Analytics tracking script. The code in this section will be displayed <strong>after</strong> the Google Analytics tracker is initialized. Read <a href="http://www.google.com/analytics/InstallingGATrackingCode.pdf">Google Analytics tracker manual</a> to learn what code goes here and how to use it.</p>
|
338 |
</td>
|
339 |
</tr>
|
340 |
<tr>
|
362 |
|
363 |
echo "</select>\n";
|
364 |
?>
|
365 |
+
<p style="margin: 5px 10px;" class="setting-description">Explicitly set the type of HTTP connection your website uses. Setting this option instead of relying on the auto detect may resolve the _gat is undefined error message.</p>
|
366 |
</td>
|
367 |
</tr>
|
368 |
</table>
|
369 |
<p class="submit">
|
370 |
+
<?php if ( function_exists('settings_fields') ) settings_fields('google-analyticator'); ?>
|
371 |
<input type='submit' name='info_update' value='Save Changes' />
|
372 |
</p>
|
373 |
</div>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: cavemonkey50
|
|
3 |
Donate link: http://cavemonkey50.com/code/
|
4 |
Tags: stats, google, analytics, tracking
|
5 |
Requires at least: 2.3
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Adds the necessary JavaScript code to enable Google Analytics.
|
10 |
|
@@ -55,6 +55,9 @@ Google's servers are slow at crawling for the tracking code. While the code may
|
|
55 |
|
56 |
== Changelog ==
|
57 |
|
|
|
|
|
|
|
58 |
**2.2** - Minor Update
|
59 |
- Adds an option to specify the GA script location instead of relying on Google's auto detect code. This may resolve the _gat is undefined errors.
|
60 |
|
3 |
Donate link: http://cavemonkey50.com/code/
|
4 |
Tags: stats, google, analytics, tracking
|
5 |
Requires at least: 2.3
|
6 |
+
Tested up to: 2.7
|
7 |
+
Stable tag: 2.21
|
8 |
|
9 |
Adds the necessary JavaScript code to enable Google Analytics.
|
10 |
|
55 |
|
56 |
== Changelog ==
|
57 |
|
58 |
+
**2.21** - Minor Update
|
59 |
+
- Adds compatibility with WordPress 2.7.
|
60 |
+
|
61 |
**2.2** - Minor Update
|
62 |
- Adds an option to specify the GA script location instead of relying on Google's auto detect code. This may resolve the _gat is undefined errors.
|
63 |
|