StatCounter – Free Real Time Visitor Stats - Version 1.3

Version Description

  • Added counter position option. Allows you to specify the position of the counter in the header or footer.
  • Added 'forced invisibility' option. Allows you to enable an invisible counter without logging into your StatCounter account.
Download this release

Release Info

Developer StatCounter
Plugin Icon StatCounter – Free Real Time Visitor Stats
Version 1.3
Comparing to
See all releases

Version 1.3

StatCounter-Wordpress-Plugin.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Plugin Name: Official StatCounter Plugin
4
+ * Version: 1.3
5
+ * Plugin URI: http://www.statcounter.com/
6
+ * Description: Adds the StatCounter tracking code to your blog. After uploading this plugin click 'Activate' (to the right) and then afterwards you must visit the <a href="options-general.php?page=StatCounter-Wordpress-Plugin.php">options page</a> and enter your StatCounter Project Info to enable logging.
7
+ * Author: Aodhan Cullen
8
+ * Author URI: http://www.statcounter.com/
9
+ */
10
+
11
+ // Constants for enabled/disabled state
12
+ define("sc_enabled" , "enabled", true);
13
+ define("sc_disabled" , "disabled", true);
14
+
15
+ // Defaults, etc.
16
+ define("key_sc_project", "sc_project", true);
17
+ define("key_sc_part", "sc_part", true);
18
+ define("key_sc_status", "sc_status", true);
19
+ define("key_sc_position", "sc_position", true);
20
+ // legacy problem with sc_security naming
21
+ define("key_sc_security", "key_sc_security", true);
22
+
23
+
24
+
25
+ define("sc_project_default", "0" , true);
26
+ define("sc_part_default", "0" , true);
27
+ define("sc_security_default", "" , true);
28
+ define("sc_status_default", sc_disabled , true);
29
+ define("sc_position_default", "footer", true);
30
+ define("sc_admin_default", sc_enabled , true);
31
+
32
+ // Create the default key and status
33
+ add_option(key_sc_status, sc_status_default, 'If StatCounter logging in turned on or off.');
34
+ add_option(key_sc_project, sc_project_default, 'Your StatCounter Project ID.');
35
+ add_option(key_sc_part, sc_part_default, 'Your StatCounter Partition ID.');
36
+ add_option(key_sc_security, sc_security_default, 'Your StatCounter Security String.');
37
+ add_option("sc_invisible", "0", 'Force invisibility.');
38
+
39
+ // Create a option page for settings
40
+ add_action('admin_menu' , 'add_sc_option_page' );
41
+ add_action( 'admin_menu', 'statcounter_admin_menu' );
42
+
43
+ function statcounter_admin_menu() {
44
+ $hook = add_submenu_page('index.php', __('StatCounter Stats'), __('StatCounter Stats'), 'publish_posts', 'statcounter', 'statcounter_reports_page');
45
+ add_action("load-$hook", 'statcounter_reports_load');
46
+ $hook = add_submenu_page('plugins.php', __('StatCounter Admin'), __('StatCounter Admin'), 'manage_options', 'statcounter_admin', 'sc_options_page');
47
+ }
48
+
49
+ function statcounter_reports_load() {
50
+ add_action('admin_head', 'statcounter_reports_head');
51
+ }
52
+
53
+ function statcounter_reports_head() {
54
+ ?>
55
+ <style type="text/css">
56
+ body { height: 100%; }
57
+ </style>
58
+ <?php
59
+ }
60
+
61
+ function statcounter_reports_page() {
62
+ $sc_project = get_option(key_sc_project);
63
+
64
+
65
+ echo '<iframe id="statcounter_frame" src="http://my.statcounter.com/project/standard/stats.php?project_id='.$sc_project.'" width="100%" height="2000">
66
+ <p>Your browser does not support iframes.</p>
67
+ </iframe>';
68
+
69
+ }
70
+
71
+
72
+
73
+ // Hook in the options page function
74
+ function add_sc_option_page() {
75
+ global $wpdb;
76
+ add_options_page('StatCounter Options', 'StatCounter', 8, basename(__FILE__), 'sc_options_page');
77
+ }
78
+
79
+ function sc_options_page() {
80
+ // If we are a postback, store the options
81
+ if ( isset( $_POST['info_update'] ) ) {
82
+ check_admin_referer();
83
+
84
+ // Update the status
85
+ $sc_status = $_POST[key_sc_status];
86
+ if (($sc_status != sc_enabled) && ($sc_status != sc_disabled))
87
+ $sc_status = sc_status_default;
88
+ update_option(key_sc_status, $sc_status);
89
+
90
+ // Update the Project ID
91
+ $sc_project = $_POST[key_sc_project];
92
+ if ($sc_project == '')
93
+ $sc_project = sc_project_default;
94
+ update_option(key_sc_project, $sc_project);
95
+
96
+ // Update the part ID
97
+ $sc_part = $_POST[key_sc_part];
98
+ if ($sc_part == '')
99
+ $sc_part = sc_part_default;
100
+ update_option(key_sc_part, $sc_part);
101
+
102
+ // Update the Security ID
103
+ $sc_security = $_POST[key_sc_security];
104
+ if ($sc_security =='')
105
+ $sc_security = sc_security_default;
106
+ update_option(key_sc_security, $sc_security);
107
+
108
+ // Update the position
109
+ $sc_position = $_POST[key_sc_position];
110
+ if (($sc_position != sc_header) && ($sc_position != sc_footer))
111
+ $sc_status = sc_position_default;
112
+ update_option(key_sc_position, $sc_position);
113
+
114
+ // Force invisibility
115
+ $sc_invisible = $_POST['sc_invisible'];
116
+ if ($sc_invisible == 1) {
117
+ update_option('sc_invisible', "1");
118
+ } else {
119
+ update_option('sc_invisible', "0");
120
+ }
121
+
122
+ // Give an updated message
123
+ echo "<div class='updated'><p><strong>StatCounter options updated</strong></p></div>";
124
+ }
125
+
126
+ // Output the options page
127
+ ?>
128
+
129
+ <form method="post" action="options-general.php?page=StatCounter-Wordpress-Plugin.php">
130
+ <div class="wrap">
131
+ <?php if ( get_option( key_sc_status ) == sc_disabled ) { ?>
132
+ <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
133
+ StatCounter Wordpress Plugin is currently <strong>DISABLED</strong>.
134
+ </div>
135
+ <?php } ?>
136
+ <?php if ( ( get_option( key_sc_project ) == "0" ) && ( get_option( key_sc_status ) != sc_disabled ) ) { ?>
137
+ <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
138
+ StatCounter Plugin is currently enabled, but the following errors are noted:<ul style="padding:0;margin:0;"><?php
139
+ echo ( get_option( key_sc_project ) == "0" ? "<li>No <strong>Project ID</strong> has been provided</li>" : "" );
140
+ ?></ul><strong>Tracking will not occur</strong>.
141
+ </div>
142
+ <?php } ?>
143
+ <h2>Using StatCounter</h2>
144
+ <blockquote><a href="http://www.statcounter.com" style="font-weight:bold;">StatCounter</a> is a free web traffic analysis service, which provides summary stats on all your traffic and a detailed analysis of your last 500 page views. This limit can be increased by subscribing to their paid service.</p>
145
+ <p>To activate the StatCounter service for your WordPress site:<ol>
146
+ <li>Register/Login to <a href="http://www.statcounter.com" style="font-weight:bold;">StatCounter</a></li>
147
+ <li>Select <a href="http://my3.statcounter.com/project/add.php" style="font-weight:bold;">Add New Project</a> from your Projects Menu</li>
148
+ <li>Complete the requested details regarding your site, then click "Next"</li>
149
+ <li>Click the "<strong>Configure & Install Code</strong>" button</li>
150
+ <li>Select and configure the type of counter your would like</li>
151
+ <li>Select "<strong>Wordpress.org (I pay for the hosting)</strong>" from the drop down list, then click "Next"</li>
152
+ <li>From the generated StatCounter Code, copy the bolded sections:<br />
153
+ '<em>var sc_project=</em><strong>1234567</strong>' - Your Project ID<br />
154
+ '<em>var sc_partition=</em><strong>12</strong>' - Your Partition Number<br />
155
+ '<em>var sc_security="</em><strong>a1b2c3d4</strong><em>"</em>' - Your Security Code (Don't grab the inverted commas)</li>
156
+ <li>Enter those details into the relevant fields below</li>
157
+ <li>Click "Update Options"</li>
158
+ </ol></blockquote>
159
+ <h2>StatCounter Options</h2>
160
+ <blockquote>
161
+ <fieldset class='options'>
162
+ <table class="editform" cellspacing="2" cellpadding="5">
163
+ <tr>
164
+ <td>
165
+ Logging:
166
+ </td>
167
+ <td>
168
+ <?php
169
+ echo "<select name='".key_sc_status."' id='".key_sc_status."'>\n";
170
+
171
+ echo "<option value='".sc_enabled."'";
172
+ if(get_option(key_sc_status) == sc_enabled)
173
+ echo " selected='selected'";
174
+ echo ">Enabled</option>\n";
175
+
176
+ echo "<option value='".sc_disabled."'";
177
+ if(get_option(key_sc_status) == sc_disabled)
178
+ echo" selected='selected'";
179
+ echo ">Disabled</option>\n";
180
+
181
+ echo "</select>\n";
182
+ ?>
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td>
187
+ Project ID:
188
+ </td>
189
+ <td>
190
+ <?php
191
+ echo "<input type='text' size='11' ";
192
+ echo "name='".key_sc_project."' ";
193
+ echo "id='".key_sc_project."' ";
194
+ echo "value='".get_option(key_sc_project)."' />\n";
195
+ ?>
196
+ </td>
197
+ </tr>
198
+ <tr>
199
+ <td>
200
+ Partition Number:
201
+ </td>
202
+ <td>
203
+ <?php
204
+ echo "<input type='text' size='3' ";
205
+ echo "name='".key_sc_part."' ";
206
+ echo "id='".key_sc_part."' ";
207
+ echo "value='".get_option(key_sc_part)."' />\n";
208
+ ?>
209
+
210
+ </td>
211
+ </tr>
212
+ <tr>
213
+ <td>
214
+ Security Code:
215
+ </td>
216
+ <td>
217
+ <?php
218
+ echo "<input type='text' size='9' ";
219
+ echo "name='".key_sc_security."' ";
220
+ echo "id='".key_sc_security."' ";
221
+ echo "value='".get_option(key_sc_security)."' />\n";
222
+ ?>
223
+ </td>
224
+ </tr>
225
+ <tr>
226
+ <td>
227
+ Counter Position:
228
+ </td>
229
+ <td>
230
+ <?php
231
+ echo "<select name='".key_sc_position."' id='".key_sc_position."'>\n";
232
+
233
+ echo "<option value='header'";
234
+ if(get_option(key_sc_position) == "header")
235
+ echo " selected='selected'";
236
+ echo ">Header</option>\n";
237
+
238
+ echo "<option value='footer'";
239
+ if(get_option(key_sc_position) != "header")
240
+ echo" selected='selected'";
241
+ echo ">Footer</option>\n";
242
+
243
+ echo "</select>\n";
244
+ ?>
245
+ </td>
246
+ </tr>
247
+ <tr>
248
+ <td>
249
+ Force invisibilty:
250
+ </td>
251
+ <td>
252
+ <?php
253
+ $checked = "";
254
+ if(get_option('sc_invisible')==1) {
255
+ $checked = "checked";
256
+ }
257
+
258
+ echo "<input type='checkbox' name='sc_invisible' id='sc_invisible' value='1' ".$checked.">\n";
259
+ ?>
260
+ </td>
261
+ </tr>
262
+ </table>
263
+ </fieldset>
264
+ </blockquote>
265
+ <p class="submit">
266
+ <input type='submit' name='info_update' value='Update Options' />
267
+ </p>
268
+ </div>
269
+ </form>
270
+
271
+ <?php
272
+ }
273
+ //print_r($_GET);
274
+ //print_r($_POST);
275
+ //die();
276
+ //echo $sc_position;
277
+ $sc_position = get_option(key_sc_position);
278
+ //die($sc_position);
279
+ if ($sc_position=="header") {
280
+ add_action('wp_head', 'add_statcounter');
281
+ } else {
282
+ add_action('wp_footer', 'add_statcounter');
283
+ }
284
+
285
+
286
+
287
+
288
+
289
+ // The guts of the StatCounter script
290
+ function add_statcounter() {
291
+ global $user_level;
292
+ $sc_project = get_option(key_sc_project);
293
+ $sc_part = get_option(key_sc_part);
294
+ $sc_security = get_option(key_sc_security);
295
+ if (
296
+ ( get_option( key_sc_status ) != sc_disabled && $sc_project > 0 )
297
+ ) {
298
+ ?>
299
+ <!-- Start of StatCounter Code -->
300
+ <script type="text/javascript">
301
+ <!--
302
+ var sc_project=<?php echo $sc_project; ?>;
303
+ var sc_partition=<?php echo $sc_part; ?>;
304
+ var sc_security="<?php echo $sc_security; ?>";
305
+ <?php
306
+ if(get_option('sc_invisible')==1) {
307
+ echo " var sc_invisible=1;\n";
308
+ }?>
309
+ //-->
310
+ </script>
311
+ <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
312
+ <!-- End of StatCounter Code -->
313
+ <?php
314
+ }
315
+ }
316
+
317
+ ?>
readme.txt ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === StatCounter - Free Real Time Visitor Stats ===
2
+ Contributors: Aodhan Cullen
3
+ Donate link: http://www.statcounter.com/
4
+ Tags: web, statistics, stats, hit, counter, visitor, ip, tracker, analytics
5
+ Requires at least: 2.0.2
6
+ Tested up to: 2.9.2
7
+ Stable tag: 1.3
8
+
9
+ StatCounter.com powered real-time detailed stats about the visitors to your blog.
10
+
11
+ == Description ==
12
+
13
+ The Official StatCounter Wordpress Plugin brings you all the powerful StatCounter features to your wordpress blog.
14
+
15
+ Including but not limited to the following:
16
+
17
+ * [Invisible Counter Option](http://www.statcounter.com/features/#invisible-counter)
18
+ * [Configurable Counter](http://www.statcounter.com/features/#configurable-counter)
19
+ * [Configurable Summary Stats](http://www.statcounter.com/features/#configurable-summary-stats)
20
+ * [Magnify User](http://www.statcounter.com/features/#magnify-user)
21
+ * [Drill Down](http://www.statcounter.com/features/#drill-down)
22
+ * [Popular Pages](http://www.statcounter.com/features/#popular-pages)
23
+ * [Entry Pages](http://www.statcounter.com/features/#entry-pages)
24
+ * [Exit Pages](http://www.statcounter.com/features/#exit-pages)
25
+ * [Came From](http://www.statcounter.com/features/#came-from)
26
+ * [Keyword Analysis](http://www.statcounter.com/features/#keyword-analysis)
27
+ * [Recent Keyword Activity](http://www.statcounter.com/features/#recent-keyword-activity)
28
+ * [Search Engine Wars](http://www.statcounter.com/features/#search-engine-wars)
29
+ * [Visitor Paths](http://www.statcounter.com/features/#visitor-paths)
30
+ * [Visit Length](http://www.statcounter.com/features/#visit-length)
31
+ * [Returning Visits](http://www.statcounter.com/features/#returning-visits)
32
+ * [Recent Pageload Activity](http://www.statcounter.com/features/#recent-pageload-activity)
33
+ * [Recent Visitor Activity](http://www.statcounter.com/features/#recent-visitor-activity)
34
+ * [Country/State/City Stats](http://www.statcounter.com/features/#country-state-city-stats)
35
+ * [Recent Visitor Google Map](http://www.statcounter.com/features/#visitor-map)
36
+ * [ISP Stats](http://www.statcounter.com/features/#isp-stats)
37
+ * [Browser Stats](http://www.statcounter.com/features/#browser-stats)
38
+ * [O.S. Stats](http://www.statcounter.com/features/#os-stats)
39
+ * [Resolution Stats](http://www.statcounter.com/features/#resolution-stats)
40
+ * [JavaScript Stats](http://www.statcounter.com/features/#javascript-stats)
41
+ * [Email Reports](http://www.statcounter.com/features/#email-reports)
42
+ * [Multiple Site Management](http://www.statcounter.com/features/#multiple-site-management)
43
+ * [User Access Management](http://www.statcounter.com/features/#user-access-management)
44
+ * [Public Stats](http://www.statcounter.com/features/#public-stats)
45
+ * [Blocking Cookie](http://www.statcounter.com/features/#blocking-cookie)
46
+
47
+ == Installation ==
48
+
49
+ StatCounter is a free web traffic analysis service, which provides summary stats on all your traffic and a detailed analysis of your last 500 page views. This limit can be increased by subscribing to their paid service.
50
+
51
+ To activate the StatCounter service for your WordPress site:
52
+
53
+ 1. Register/Login to [StatCounter](http://www.statcounter.com/)
54
+ 1. Select Add New Project from your Projects Menu
55
+ 1. Complete the requested details regarding your site, then click "Next"
56
+ 1. Click the "Configure & Install Code" button
57
+ 1. Select and configure the type of counter your would like
58
+ 1. Select "Wordpress.org (I pay for the hosting)" from the drop down list, then click "Next"
59
+ 1. From the generated StatCounter Code, copy the bolded sections:
60
+ 'var sc_project=1234567' - Your Project ID
61
+ 'var sc_partition=12' - Your Partition ID
62
+ 'var sc_security="a1b2c3d4"' - Your Security String (Don't grab the inverted commas)
63
+ 1. Enter those details into the relevant fields below
64
+ 1. Click "Update Options"
65
+
66
+
67
+ == Frequently Asked Questions ==
68
+
69
+ = Do you have any questions? =
70
+
71
+ [Please contact us here with your query.](http://www.statcounter.com/contactus.html)
72
+
73
+ == Screenshots ==
74
+
75
+ 1. Example StatCounter.com Summary Stats
76
+ 2. Using the magnify tool, you can "zoom in" on individual visitors and get a detailed report on where they are from, their system settings, and most importantly, what link reffered them to your site and their navigation path through your site.
77
+
78
+ == Changes ==
79
+
80
+ = 1.3 =
81
+ * Added counter position option. Allows you to specify the position of the counter in the header or footer.
82
+ * Added 'forced invisibility' option. Allows you to enable an invisible counter without logging into your StatCounter account.
83
+
84
+ = 1.2 =
85
+ * Fixed critical bug.
86
+
87
+ = 1.1 =
88
+ * Added ability to view StatCounter Stats from within the Wordpress Admin.
screenshot-1.gif ADDED
Binary file
screenshot-2.jpg ADDED
Binary file