Google Analytics - Version 1.0.7

Version Description

Download this release

Release Info

Developer ShareThis
Plugin Icon wp plugin Google Analytics
Version 1.0.7
Comparing to
See all releases

Version 1.0.7

Files changed (6) hide show
  1. LICENSE +20 -0
  2. googleanalytics.php +67 -0
  3. options.php +26 -0
  4. readme.txt +27 -0
  5. screenshot-1.png +0 -0
  6. screenshot-2.png +0 -0
LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2009 - 2016 Kevin Sylvestre
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
googleanalytics.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Google Analytics
4
+ Plugin URI: http://wordpress.org/extend/plugins/googleanalytics/
5
+ Description: Enables <a href="http://www.google.com/analytics/">Google Analytics</a> on all pages.
6
+ Version: 1.0.7
7
+ Author: Kevin Sylvestre
8
+ Author URI: http://ksylvest.com/
9
+ */
10
+
11
+ if (!defined('WP_CONTENT_URL'))
12
+ define('WP_CONTENT_URL', get_option('siteurl').'/wp-content');
13
+ if (!defined('WP_CONTENT_DIR'))
14
+ define('WP_CONTENT_DIR', ABSPATH.'wp-content');
15
+ if (!defined('WP_PLUGIN_URL'))
16
+ define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
17
+ if (!defined('WP_PLUGIN_DIR'))
18
+ define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins');
19
+
20
+ function activate_googleanalytics() {
21
+ add_option('web_property_id', 'UA-0000000-0');
22
+ }
23
+
24
+ function deactive_googleanalytics() {
25
+ delete_option('web_property_id');
26
+ }
27
+
28
+ function admin_init_googleanalytics() {
29
+ register_setting('googleanalytics', 'web_property_id');
30
+ }
31
+
32
+ function admin_menu_googleanalytics() {
33
+ add_options_page('Google Analytics', 'Google Analytics', 'manage_options', 'googleanalytics', 'options_page_googleanalytics');
34
+ }
35
+
36
+ function options_page_googleanalytics() {
37
+ include(WP_PLUGIN_DIR.'/googleanalytics/options.php');
38
+ }
39
+
40
+ function googleanalytics() {
41
+ $web_property_id = get_option('web_property_id');
42
+ ?>
43
+ <script>
44
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
45
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
46
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
47
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
48
+
49
+ ga('create', '<?php echo $web_property_id ?>', 'auto');
50
+ ga('send', 'pageview');
51
+ </script>
52
+ <?php
53
+ }
54
+
55
+ register_activation_hook(__FILE__, 'activate_googleanalytics');
56
+ register_deactivation_hook(__FILE__, 'deactive_googleanalytics');
57
+
58
+ if (is_admin()) {
59
+ add_action('admin_init', 'admin_init_googleanalytics');
60
+ add_action('admin_menu', 'admin_menu_googleanalytics');
61
+ }
62
+
63
+ if (!is_admin()) {
64
+ add_action('wp_head', 'googleanalytics');
65
+ }
66
+
67
+ ?>
options.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2>Google Analytics</h2>
3
+
4
+ <form method="post" action="options.php">
5
+ <?php wp_nonce_field('update-options'); ?>
6
+ <?php settings_fields('googleanalytics'); ?>
7
+
8
+ <table class="form-table">
9
+
10
+ <tr valign="top">
11
+ <th scope="row">Web Property ID:</th>
12
+ <td><input type="text" name="web_property_id" value="<?php echo get_option('web_property_id'); ?>" /></td>
13
+ </tr>
14
+
15
+ </tr>
16
+
17
+ </table>
18
+
19
+ <input type="hidden" name="action" value="update" />
20
+
21
+ <p class="submit">
22
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
23
+ </p>
24
+
25
+ </form>
26
+ </div>
readme.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Google Analytics ===
2
+ Contributors: kevinsylvestre
3
+ Tags: javascript, google, analytics
4
+ Requires at least: 2.7
5
+ Tested up to: 4.6.1
6
+ Stable tag: 1.0.7
7
+
8
+ Enables google analytics on all pages.
9
+
10
+ == Description ==
11
+
12
+ This plugin adds the required javascript for google analytics.
13
+
14
+ For more information visit:
15
+
16
+ [Google Analytics](http://www.google.com/analytics)
17
+
18
+ == Installation ==
19
+
20
+ 1. Upload `googleanalytics` directory to the `/wp-content/plugins/` directory
21
+ 2. Activate the plugin through the Plugins menu in your WordPress dashboard
22
+ 3. Add the web property ID from Google Analytics (UA-0000000-0) to the settings (Admin > Settings > Google Analytics)
23
+
24
+ == Screenshots ==
25
+
26
+ 1. Modified settings panel with Google Analytics.
27
+ 2. Google Analytics settings page.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file