Google Universal Analytics - Version 2.2

Version Description

  • Display Advertising feature added.
  • IP Anonymization option is now available.
Download this release

Release Info

Developer audriusd
Plugin Icon wp plugin Google Universal Analytics
Version 2.2
Comparing to
See all releases

Code changes from version 2.1.2 to 2.2

assets/gua-main.js CHANGED
@@ -69,6 +69,26 @@ jQuery(document).ready(function(e) {
69
  var track_links = 'off';
70
 
71
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  if(jQuery('#tracking_off_for_role').is(':checked')){
74
 
@@ -107,6 +127,10 @@ jQuery(document).ready(function(e) {
107
  'property_id' : property_id,
108
 
109
  'track_links' : track_links,
 
 
 
 
110
 
111
  'tracking_off_for_role' : tracking_off_for_role,
112
 
69
  var track_links = 'off';
70
 
71
  }
72
+
73
+ if(jQuery('#enable_display').is(':checked')){
74
+
75
+ var enable_display = 'on';
76
+
77
+ }else{
78
+
79
+ var enable_display = 'off';
80
+
81
+ }
82
+
83
+ if(jQuery('#anonymize_ip').is(':checked')){
84
+
85
+ var anonymize_ip = 'on';
86
+
87
+ }else{
88
+
89
+ var anonymize_ip = 'off';
90
+
91
+ }
92
 
93
  if(jQuery('#tracking_off_for_role').is(':checked')){
94
 
127
  'property_id' : property_id,
128
 
129
  'track_links' : track_links,
130
+
131
+ 'enable_display' : enable_display,
132
+
133
+ 'anonymize_ip' : anonymize_ip,
134
 
135
  'tracking_off_for_role' : tracking_off_for_role,
136
 
classic/classic-analytics.php CHANGED
@@ -57,6 +57,6 @@
57
  </form>
58
  </div>
59
  <div class="clearfix"></div>
60
- <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.1.2&utm_content=Google%20Classic%20Analytics&utm_campaign=WordPress%20plugins" title="Google Universal Analytics">OnlineAds.lt</a> </div>
61
  </div>
62
  </br>
57
  </form>
58
  </div>
59
  <div class="clearfix"></div>
60
+ <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.2&utm_content=Google%20Classic%20Analytics&utm_campaign=WordPress%20plugins" title="Google Universal Analytics">OnlineAds.lt</a> </div>
61
  </div>
62
  </br>
classic/custom-analytics.php CHANGED
@@ -57,6 +57,6 @@
57
  </form>
58
  </div>
59
  <div class="clearfix"></div>
60
- <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.1.2&utm_content=Google%20Custom%20Analytics&utm_campaign=WordPress%20plugins">OnlineAds.lt</a> </div>
61
  </div>
62
  </br>
57
  </form>
58
  </div>
59
  <div class="clearfix"></div>
60
+ <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.2&utm_content=Google%20Custom%20Analytics&utm_campaign=WordPress%20plugins">OnlineAds.lt</a> </div>
61
  </div>
62
  </br>
googleanalytics.php CHANGED
@@ -1,292 +1,595 @@
1
- <?php
2
- /*
3
- Plugin Name: Google Universal Analytics
4
- Plugin URI: http://wordpress.org/extend/plugins/google-universal-analytics/
5
- Description: Adds <a href="http://www.google.com/analytics/">Google Analytics</a> tracking code on all pages.
6
- Version: 2.1.2
7
- Author: Audrius Dobilinskas
8
- Author URI: http://onlineads.lt/
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 deactive_google_universal_analytics() {
21
- delete_option('web_property_id');
22
- delete_option('in_footer');
23
- delete_option('plugin_switch');
24
- delete_option('track_links');
25
- delete_option('tracking_off_for_this_role');
26
- delete_option('tracking_off_for_role');
27
- //classic_options
28
- delete_option('classic_property_id');
29
- delete_option('classic_in_footer');
30
- delete_option('classic_plugin_switch');
31
- delete_option('classic_tracking_off_for_role');
32
- delete_option('classic_tracking_off_for_this_role');
33
-
34
- //custom_options
35
- delete_option('custom_in_footer');
36
- delete_option('custom_plugin_switch');
37
- delete_option('custom_web_property_id');
38
- delete_option('custom_tracking_off_for_role');
39
- delete_option('custom_tracking_off_for_this_role');
40
- }
41
-
42
-
43
- function admin_menu_google_universal_analytics() {
44
-
45
-
46
- global $settings_page, $settings_page1, $classic_page, $cutom_page;
47
-
48
- $settings_page = add_menu_page( 'Google Universal Analytics', 'Google Universal Analytics', 'manage_options', 'google_universal_analytics', 'options_page_google_universal_analytics' );
49
- add_submenu_page('google_universal_analytics','','','manage_options','google_universal_analytics','options_page_google_universal_analytics');
50
- $settings_page1 = add_submenu_page( 'google_universal_analytics', 'Settings', 'Settings', 'manage_options', 'google_universal_analytics', 'options_page_google_universal_analytics' );
51
- $classic_page = add_submenu_page( 'google_universal_analytics', 'Classic Analytics', 'Classic Analytics', 'manage_options', 'classic_analytics', 'classic_analytics_page_google_universal_analytics' );
52
-
53
- $cutom_page = add_submenu_page( 'google_universal_analytics', 'Custom Tracker', 'Custom Tracker', 'manage_options', 'custom_analytics', 'custom_analytics_page_google_universal_analytics' );
54
-
55
- }
56
-
57
- function options_page_google_universal_analytics() {
58
- include(WP_PLUGIN_DIR.'/google-universal-analytics/options.php');
59
- }
60
- function classic_analytics_page_google_universal_analytics() {
61
- include(WP_PLUGIN_DIR.'/google-universal-analytics/classic/classic-analytics.php');
62
- }
63
- function custom_analytics_page_google_universal_analytics() {
64
- include(WP_PLUGIN_DIR.'/google-universal-analytics/classic/custom-analytics.php');
65
- }
66
-
67
- function google_universal_analytics() {
68
- require 'tracking-code.php';
69
- }
70
-
71
- function google_classic_analytics() {
72
- $classic_property_id = get_option('classic_property_id');
73
- $classic_analytics_code = "<script type='text/javascript'>
74
-
75
- var _gaq = _gaq || [];
76
- _gaq.push(['_setAccount', '$classic_property_id']);
77
- _gaq.push(['_trackPageview']);
78
-
79
- (function() {
80
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
81
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
82
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
83
- })();
84
-
85
- </script>";
86
- echo $classic_analytics_code;
87
- }
88
- function google_custom_analytics() {
89
- echo get_option('custom_web_property_id');
90
- }
91
-
92
- function google_universal_analytics_scripts($hook){
93
- global $settings_page, $settings_page1, $classic_page, $cutom_page;
94
-
95
- if($hook != $settings_page && $hook != $settings_page1 && $hook != $classic_page && $hook != $cutom_page )
96
- return;
97
-
98
- //register styles
99
- wp_register_style( 'bootstrap-css', plugins_url( 'google-universal-analytics/bootstrap/css/bootstrap.min.css' , dirname(__FILE__) ) );
100
- wp_register_style( 'bootstrap-switch-css', plugins_url( 'google-universal-analytics/bootstrap/css/bootstrap-switch.min.css' , dirname(__FILE__) ) );
101
- wp_register_style( 'main-css', plugins_url( 'google-universal-analytics/assets/gua-main.css' , dirname(__FILE__) ) );
102
-
103
- //register scripts
104
- wp_register_script( 'google-js', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', array(), '', true );
105
- wp_register_script( 'bootstrap-js', plugins_url( 'google-universal-analytics/bootstrap/js/bootstrap.min.js' , dirname(__FILE__) ), array('google-js'), '', true );
106
- wp_register_script( 'bootstrap-switch-js', plugins_url( 'google-universal-analytics/bootstrap/js/bootstrap-switch.min.js' , dirname(__FILE__) ) , array('bootstrap-js'),'',true );
107
- wp_register_script( 'main-js', plugins_url( 'google-universal-analytics/assets/gua-main.js' , dirname(__FILE__) ) , array('google-js'),'',true );
108
-
109
-
110
- //enqueue styles
111
- wp_enqueue_style( 'bootstrap-css' );
112
- wp_enqueue_style( 'bootstrap-switch-css' );
113
- wp_enqueue_style( 'main-css' );
114
-
115
- //enqueue scripts
116
- wp_enqueue_script( 'google-js' );
117
- wp_enqueue_script( 'bootstrap-js' );
118
- wp_enqueue_script( 'bootstrap-switch-js' );
119
- wp_enqueue_script( 'main-js' );
120
- }
121
-
122
-
123
- register_deactivation_hook(__FILE__, 'deactive_google_universal_analytics');
124
-
125
- if (is_admin()) {
126
- add_action('admin_enqueue_scripts', 'google_universal_analytics_scripts');
127
- add_action('admin_menu', 'admin_menu_google_universal_analytics');
128
- }
129
-
130
- add_action('init', 'display_google_universal_analytics_code');
131
- function display_google_universal_analytics_code(){
132
- global $current_user;
133
- $user_roles = $current_user->roles;
134
- $user_role = array_shift($user_roles);
135
-
136
-
137
- if(get_option('tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('tracking_off_for_this_role'))!=0){
138
- if (!is_admin() && get_option('plugin_switch')=='on') {
139
- if(get_option('in_footer')=='on'){
140
- add_action('wp_footer', 'google_universal_analytics');
141
- }else{
142
- add_action('wp_head', 'google_universal_analytics');
143
- }
144
- }
145
- }elseif(is_user_logged_in() && get_option('tracking_off_for_role')!='on'){
146
- if (!is_admin() && get_option('plugin_switch')=='on') {
147
- if(get_option('in_footer')=='on'){
148
- add_action('wp_footer', 'google_universal_analytics');
149
- }else{
150
- add_action('wp_head', 'google_universal_analytics');
151
- }
152
- }
153
-
154
- }elseif(!is_user_logged_in()){
155
- if (!is_admin() && get_option('plugin_switch')=='on') {
156
- if(get_option('in_footer')=='on'){
157
- add_action('wp_footer', 'google_universal_analytics');
158
- }else{
159
- add_action('wp_head', 'google_universal_analytics');
160
- }
161
- }
162
-
163
- }
164
-
165
-
166
- if(get_option('custom_tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('custom_tracking_off_for_this_role'))!=0){
167
- if (!is_admin() && get_option('custom_plugin_switch')=='on') {
168
- if(get_option('custom_in_footer')=='on'){
169
- add_action('wp_footer', 'google_custom_analytics');
170
- }else{
171
- add_action('wp_head', 'google_custom_analytics');
172
- }
173
- }
174
- }elseif(is_user_logged_in() && get_option('custom_tracking_off_for_role')!='on'){
175
- if (!is_admin() && get_option('custom_plugin_switch')=='on') {
176
- if(get_option('custom_in_footer')=='on'){
177
- add_action('wp_footer', 'google_custom_analytics');
178
- }else{
179
- add_action('wp_head', 'google_custom_analytics');
180
- }
181
- }
182
-
183
- }elseif(!is_user_logged_in()){
184
- if (!is_admin() && get_option('custom_plugin_switch')=='on') {
185
- if(get_option('custom_in_footer')=='on'){
186
- add_action('wp_footer', 'google_custom_analytics');
187
- }else{
188
- add_action('wp_head', 'google_custom_analytics');
189
- }
190
- }
191
-
192
- }
193
-
194
- if(get_option('classic_tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('classic_tracking_off_for_this_role'))!=0){
195
- if (!is_admin() && get_option('classic_plugin_switch')=='on') {
196
- if(get_option('classic_in_footer')=='on'){
197
- add_action('wp_footer', 'google_classic_analytics');
198
- }else{
199
- add_action('wp_head', 'google_classic_analytics');
200
- }
201
- }
202
- }elseif(is_user_logged_in() && get_option('classic_tracking_off_for_role')!='on'){
203
- if (!is_admin() && get_option('classic_plugin_switch')=='on') {
204
- if(get_option('classic_in_footer')=='on'){
205
- add_action('wp_footer', 'google_classic_analytics');
206
- }else{
207
- add_action('wp_head', 'google_classic_analytics');
208
- }
209
- }
210
- }elseif(!is_user_logged_in()){
211
- if (!is_admin() && get_option('classic_plugin_switch')=='on') {
212
- if(get_option('classic_in_footer')=='on'){
213
- add_action('wp_footer', 'google_classic_analytics');
214
- }else{
215
- add_action('wp_head', 'google_classic_analytics');
216
- }
217
- }
218
- }
219
-
220
- }
221
-
222
-
223
-
224
- function save_google_universal_analytics_settings() {
225
- // The $_REQUEST contains all the data sent via ajax
226
- if ( isset($_REQUEST) ) {
227
- $property_id = $_REQUEST['property_id'];
228
- $in_footer = $_REQUEST['in_footer'];
229
- $plugin_switch = $_REQUEST['plugin_switch'];
230
- $track_links = $_REQUEST['track_links'];
231
- $tracking_off_for_this_role = $_REQUEST['tracking_off_for_this_role'];
232
- $tracking_off_for_role = $_REQUEST['tracking_off_for_role'];
233
-
234
-
235
- update_option('web_property_id', $property_id);
236
- update_option('in_footer', $in_footer);
237
- update_option('plugin_switch', $plugin_switch);
238
- update_option('track_links', $track_links);
239
- update_option('tracking_off_for_this_role', $tracking_off_for_this_role);
240
- update_option('tracking_off_for_role', $tracking_off_for_role);
241
- }
242
- // Always die in functions echoing ajax content
243
- die();
244
- }
245
-
246
- function save_google_classic_analytics_settings() {
247
- // The $_REQUEST contains all the data sent via ajax
248
- if ( isset($_REQUEST) ) {
249
- $classic_property_id = $_REQUEST['classic_property_id'];
250
- $classic_in_footer = $_REQUEST['classic_in_footer'];
251
- $classic_plugin_switch = $_REQUEST['classic_plugin_switch'];
252
- $classic_tracking_off_for_role = $_REQUEST['classic_tracking_off_for_role'];
253
- $classic_tracking_off_for_this_role = $_REQUEST['classic_tracking_off_for_this_role'];
254
-
255
-
256
- update_option('classic_property_id', $classic_property_id);
257
- update_option('classic_in_footer', $classic_in_footer);
258
- update_option('classic_plugin_switch', $classic_plugin_switch);
259
- update_option('classic_tracking_off_for_role', $classic_tracking_off_for_role);
260
- update_option('classic_tracking_off_for_this_role', $classic_tracking_off_for_this_role);
261
- }
262
- // Always die in functions echoing ajax content
263
- die();
264
- }
265
- function save_google_custom_analytics_settings() {
266
- // The $_REQUEST contains all the data sent via ajax
267
- if ( isset($_REQUEST) ) {
268
- $custom_in_footer = $_REQUEST['custom_in_footer'];
269
- $custom_plugin_switch = $_REQUEST['custom_plugin_switch'];
270
- $custom_web_property_id = $_REQUEST['custom_web_property_id'];
271
- $custom_web_property_id = stripslashes($custom_web_property_id);
272
- $custom_tracking_off_for_role = $_REQUEST['custom_tracking_off_for_role'];
273
- $custom_tracking_off_for_this_role = $_REQUEST['custom_tracking_off_for_this_role'];
274
-
275
-
276
- update_option('custom_in_footer', $custom_in_footer);
277
- update_option('custom_plugin_switch', $custom_plugin_switch);
278
- update_option('custom_web_property_id', $custom_web_property_id);
279
- update_option('custom_tracking_off_for_role', $custom_tracking_off_for_role);
280
- update_option('custom_tracking_off_for_this_role', $custom_tracking_off_for_this_role);
281
- }
282
- // Always die in functions echoing ajax content
283
- die();
284
- }
285
-
286
-
287
- add_action( 'wp_ajax_save_google_universal_analytics_settings', 'save_google_universal_analytics_settings' );
288
- add_action( 'wp_ajax_save_google_classic_analytics_settings', 'save_google_classic_analytics_settings' );
289
- add_action( 'wp_ajax_save_google_custom_analytics_settings', 'save_google_custom_analytics_settings' );
290
-
291
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  ?>
1
+ <?php
2
+
3
+ /*
4
+
5
+ Plugin Name: Google Universal Analytics
6
+
7
+ Plugin URI: http://wordpress.org/extend/plugins/google-universal-analytics/
8
+
9
+ Description: Adds <a href="http://www.google.com/analytics/">Google Analytics</a> tracking code on all pages.
10
+
11
+ Version: 2.2
12
+
13
+ Author: Audrius Dobilinskas
14
+
15
+ Author URI: http://onlineads.lt/
16
+
17
+ */
18
+
19
+
20
+
21
+ if (!defined('WP_CONTENT_URL'))
22
+
23
+ define('WP_CONTENT_URL', get_option('siteurl').'/wp-content');
24
+
25
+ if (!defined('WP_CONTENT_DIR'))
26
+
27
+ define('WP_CONTENT_DIR', ABSPATH.'wp-content');
28
+
29
+ if (!defined('WP_PLUGIN_URL'))
30
+
31
+ define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
32
+
33
+ if (!defined('WP_PLUGIN_DIR'))
34
+
35
+ define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins');
36
+
37
+
38
+
39
+ function deactive_google_universal_analytics() {
40
+
41
+ delete_option('web_property_id');
42
+
43
+ delete_option('in_footer');
44
+
45
+ delete_option('plugin_switch');
46
+
47
+ delete_option('track_links');
48
+
49
+ delete_option('enable_display');
50
+
51
+ delete_option('anonymize_ip');
52
+
53
+ delete_option('tracking_off_for_this_role');
54
+
55
+ delete_option('tracking_off_for_role');
56
+
57
+ //classic_options
58
+
59
+ delete_option('classic_property_id');
60
+
61
+ delete_option('classic_in_footer');
62
+
63
+ delete_option('classic_plugin_switch');
64
+
65
+ delete_option('classic_tracking_off_for_role');
66
+
67
+ delete_option('classic_tracking_off_for_this_role');
68
+
69
+
70
+
71
+ //custom_options
72
+
73
+ delete_option('custom_in_footer');
74
+
75
+ delete_option('custom_plugin_switch');
76
+
77
+ delete_option('custom_web_property_id');
78
+
79
+ delete_option('custom_tracking_off_for_role');
80
+
81
+ delete_option('custom_tracking_off_for_this_role');
82
+
83
+ }
84
+
85
+
86
+
87
+
88
+
89
+ function admin_menu_google_universal_analytics() {
90
+
91
+
92
+
93
+
94
+
95
+ global $settings_page, $settings_page1, $classic_page, $cutom_page;
96
+
97
+
98
+
99
+ $settings_page = add_menu_page( 'Google Universal Analytics', 'Google Universal Analytics', 'manage_options', 'google_universal_analytics', 'options_page_google_universal_analytics' );
100
+
101
+ add_submenu_page('google_universal_analytics','','','manage_options','google_universal_analytics','options_page_google_universal_analytics');
102
+
103
+ $settings_page1 = add_submenu_page( 'google_universal_analytics', 'Universal Analytics', 'Universal Analytics', 'manage_options', 'google_universal_analytics', 'options_page_google_universal_analytics' );
104
+
105
+ $classic_page = add_submenu_page( 'google_universal_analytics', 'Classic Analytics', 'Classic Analytics', 'manage_options', 'classic_analytics', 'classic_analytics_page_google_universal_analytics' );
106
+
107
+
108
+
109
+ $cutom_page = add_submenu_page( 'google_universal_analytics', 'Custom Tracker', 'Custom Tracker', 'manage_options', 'custom_analytics', 'custom_analytics_page_google_universal_analytics' );
110
+
111
+
112
+
113
+ }
114
+
115
+
116
+
117
+ function options_page_google_universal_analytics() {
118
+
119
+ include(WP_PLUGIN_DIR.'/google-universal-analytics/options.php');
120
+
121
+ }
122
+
123
+ function classic_analytics_page_google_universal_analytics() {
124
+
125
+ include(WP_PLUGIN_DIR.'/google-universal-analytics/classic/classic-analytics.php');
126
+
127
+ }
128
+
129
+ function custom_analytics_page_google_universal_analytics() {
130
+
131
+ include(WP_PLUGIN_DIR.'/google-universal-analytics/classic/custom-analytics.php');
132
+
133
+ }
134
+
135
+
136
+
137
+ function google_universal_analytics() {
138
+
139
+ require 'tracking-code.php';
140
+
141
+ }
142
+
143
+
144
+
145
+ function google_classic_analytics() {
146
+
147
+ $classic_property_id = get_option('classic_property_id');
148
+
149
+ $classic_analytics_code = "<script type='text/javascript'>
150
+
151
+
152
+
153
+ var _gaq = _gaq || [];
154
+
155
+ _gaq.push(['_setAccount', '$classic_property_id']);
156
+
157
+ _gaq.push(['_trackPageview']);
158
+
159
+
160
+
161
+ (function() {
162
+
163
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
164
+
165
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
166
+
167
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
168
+
169
+ })();
170
+
171
+
172
+
173
+ </script>";
174
+
175
+ echo $classic_analytics_code;
176
+
177
+ }
178
+
179
+ function google_custom_analytics() {
180
+
181
+ echo get_option('custom_web_property_id');
182
+
183
+ }
184
+
185
+
186
+
187
+ function google_universal_analytics_scripts($hook){
188
+
189
+ global $settings_page, $settings_page1, $classic_page, $cutom_page;
190
+
191
+
192
+
193
+ if($hook != $settings_page && $hook != $settings_page1 && $hook != $classic_page && $hook != $cutom_page )
194
+
195
+ return;
196
+
197
+
198
+
199
+ //register styles
200
+
201
+ wp_register_style( 'bootstrap-css', plugins_url( 'google-universal-analytics/bootstrap/css/bootstrap.min.css' , dirname(__FILE__) ) );
202
+
203
+ wp_register_style( 'bootstrap-switch-css', plugins_url( 'google-universal-analytics/bootstrap/css/bootstrap-switch.min.css' , dirname(__FILE__) ) );
204
+
205
+ wp_register_style( 'main-css', plugins_url( 'google-universal-analytics/assets/gua-main.css' , dirname(__FILE__) ) );
206
+
207
+
208
+
209
+ //register scripts
210
+
211
+ wp_register_script( 'google-js', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', array(), '', true );
212
+
213
+ wp_register_script( 'bootstrap-js', plugins_url( 'google-universal-analytics/bootstrap/js/bootstrap.min.js' , dirname(__FILE__) ), array('google-js'), '', true );
214
+
215
+ wp_register_script( 'bootstrap-switch-js', plugins_url( 'google-universal-analytics/bootstrap/js/bootstrap-switch.min.js' , dirname(__FILE__) ) , array('bootstrap-js'),'',true );
216
+
217
+ wp_register_script( 'main-js', plugins_url( 'google-universal-analytics/assets/gua-main.js' , dirname(__FILE__) ) , array('google-js'),'',true );
218
+
219
+
220
+
221
+
222
+
223
+ //enqueue styles
224
+
225
+ wp_enqueue_style( 'bootstrap-css' );
226
+
227
+ wp_enqueue_style( 'bootstrap-switch-css' );
228
+
229
+ wp_enqueue_style( 'main-css' );
230
+
231
+
232
+
233
+ //enqueue scripts
234
+
235
+ wp_enqueue_script( 'google-js' );
236
+
237
+ wp_enqueue_script( 'bootstrap-js' );
238
+
239
+ wp_enqueue_script( 'bootstrap-switch-js' );
240
+
241
+ wp_enqueue_script( 'main-js' );
242
+
243
+ }
244
+
245
+
246
+
247
+
248
+
249
+ register_deactivation_hook(__FILE__, 'deactive_google_universal_analytics');
250
+
251
+
252
+
253
+ if (is_admin()) {
254
+
255
+ add_action('admin_enqueue_scripts', 'google_universal_analytics_scripts');
256
+
257
+ add_action('admin_menu', 'admin_menu_google_universal_analytics');
258
+
259
+ }
260
+
261
+
262
+
263
+ add_action('init', 'display_google_universal_analytics_code');
264
+
265
+ function display_google_universal_analytics_code(){
266
+
267
+ global $current_user;
268
+
269
+ $user_roles = $current_user->roles;
270
+
271
+ $user_role = array_shift($user_roles);
272
+
273
+
274
+
275
+
276
+
277
+ if(get_option('tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('tracking_off_for_this_role'))!=0){
278
+
279
+ if (!is_admin() && get_option('plugin_switch')=='on') {
280
+
281
+ if(get_option('in_footer')=='on'){
282
+
283
+ add_action('wp_footer', 'google_universal_analytics');
284
+
285
+ }else{
286
+
287
+ add_action('wp_head', 'google_universal_analytics');
288
+
289
+ }
290
+
291
+ }
292
+
293
+ }elseif(is_user_logged_in() && get_option('tracking_off_for_role')!='on'){
294
+
295
+ if (!is_admin() && get_option('plugin_switch')=='on') {
296
+
297
+ if(get_option('in_footer')=='on'){
298
+
299
+ add_action('wp_footer', 'google_universal_analytics');
300
+
301
+ }else{
302
+
303
+ add_action('wp_head', 'google_universal_analytics');
304
+
305
+ }
306
+
307
+ }
308
+
309
+
310
+
311
+ }elseif(!is_user_logged_in()){
312
+
313
+ if (!is_admin() && get_option('plugin_switch')=='on') {
314
+
315
+ if(get_option('in_footer')=='on'){
316
+
317
+ add_action('wp_footer', 'google_universal_analytics');
318
+
319
+ }else{
320
+
321
+ add_action('wp_head', 'google_universal_analytics');
322
+
323
+ }
324
+
325
+ }
326
+
327
+
328
+
329
+ }
330
+
331
+
332
+
333
+
334
+
335
+ if(get_option('custom_tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('custom_tracking_off_for_this_role'))!=0){
336
+
337
+ if (!is_admin() && get_option('custom_plugin_switch')=='on') {
338
+
339
+ if(get_option('custom_in_footer')=='on'){
340
+
341
+ add_action('wp_footer', 'google_custom_analytics');
342
+
343
+ }else{
344
+
345
+ add_action('wp_head', 'google_custom_analytics');
346
+
347
+ }
348
+
349
+ }
350
+
351
+ }elseif(is_user_logged_in() && get_option('custom_tracking_off_for_role')!='on'){
352
+
353
+ if (!is_admin() && get_option('custom_plugin_switch')=='on') {
354
+
355
+ if(get_option('custom_in_footer')=='on'){
356
+
357
+ add_action('wp_footer', 'google_custom_analytics');
358
+
359
+ }else{
360
+
361
+ add_action('wp_head', 'google_custom_analytics');
362
+
363
+ }
364
+
365
+ }
366
+
367
+
368
+
369
+ }elseif(!is_user_logged_in()){
370
+
371
+ if (!is_admin() && get_option('custom_plugin_switch')=='on') {
372
+
373
+ if(get_option('custom_in_footer')=='on'){
374
+
375
+ add_action('wp_footer', 'google_custom_analytics');
376
+
377
+ }else{
378
+
379
+ add_action('wp_head', 'google_custom_analytics');
380
+
381
+ }
382
+
383
+ }
384
+
385
+
386
+
387
+ }
388
+
389
+
390
+
391
+ if(get_option('classic_tracking_off_for_role')=='on' && strcasecmp($user_role , get_option('classic_tracking_off_for_this_role'))!=0){
392
+
393
+ if (!is_admin() && get_option('classic_plugin_switch')=='on') {
394
+
395
+ if(get_option('classic_in_footer')=='on'){
396
+
397
+ add_action('wp_footer', 'google_classic_analytics');
398
+
399
+ }else{
400
+
401
+ add_action('wp_head', 'google_classic_analytics');
402
+
403
+ }
404
+
405
+ }
406
+
407
+ }elseif(is_user_logged_in() && get_option('classic_tracking_off_for_role')!='on'){
408
+
409
+ if (!is_admin() && get_option('classic_plugin_switch')=='on') {
410
+
411
+ if(get_option('classic_in_footer')=='on'){
412
+
413
+ add_action('wp_footer', 'google_classic_analytics');
414
+
415
+ }else{
416
+
417
+ add_action('wp_head', 'google_classic_analytics');
418
+
419
+ }
420
+
421
+ }
422
+
423
+ }elseif(!is_user_logged_in()){
424
+
425
+ if (!is_admin() && get_option('classic_plugin_switch')=='on') {
426
+
427
+ if(get_option('classic_in_footer')=='on'){
428
+
429
+ add_action('wp_footer', 'google_classic_analytics');
430
+
431
+ }else{
432
+
433
+ add_action('wp_head', 'google_classic_analytics');
434
+
435
+ }
436
+
437
+ }
438
+
439
+ }
440
+
441
+
442
+
443
+ }
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+ function save_google_universal_analytics_settings() {
452
+
453
+ // The $_REQUEST contains all the data sent via ajax
454
+
455
+ if ( isset($_REQUEST) ) {
456
+
457
+ $property_id = $_REQUEST['property_id'];
458
+
459
+ $in_footer = $_REQUEST['in_footer'];
460
+
461
+ $plugin_switch = $_REQUEST['plugin_switch'];
462
+
463
+ $track_links = $_REQUEST['track_links'];
464
+
465
+ $enable_display = $_REQUEST['enable_display'];
466
+
467
+ $anonymize_ip = $_REQUEST['anonymize_ip'];
468
+
469
+ $tracking_off_for_this_role = $_REQUEST['tracking_off_for_this_role'];
470
+
471
+ $tracking_off_for_role = $_REQUEST['tracking_off_for_role'];
472
+
473
+
474
+
475
+
476
+
477
+ update_option('web_property_id', $property_id);
478
+
479
+ update_option('in_footer', $in_footer);
480
+
481
+ update_option('plugin_switch', $plugin_switch);
482
+
483
+ update_option('track_links', $track_links);
484
+
485
+ update_option('enable_display', $enable_display);
486
+
487
+ update_option('anonymize_ip', $anonymize_ip);
488
+
489
+ update_option('tracking_off_for_this_role', $tracking_off_for_this_role);
490
+
491
+ update_option('tracking_off_for_role', $tracking_off_for_role);
492
+
493
+ }
494
+
495
+ // Always die in functions echoing ajax content
496
+
497
+ die();
498
+
499
+ }
500
+
501
+
502
+
503
+ function save_google_classic_analytics_settings() {
504
+
505
+ // The $_REQUEST contains all the data sent via ajax
506
+
507
+ if ( isset($_REQUEST) ) {
508
+
509
+ $classic_property_id = $_REQUEST['classic_property_id'];
510
+
511
+ $classic_in_footer = $_REQUEST['classic_in_footer'];
512
+
513
+ $classic_plugin_switch = $_REQUEST['classic_plugin_switch'];
514
+
515
+ $classic_tracking_off_for_role = $_REQUEST['classic_tracking_off_for_role'];
516
+
517
+ $classic_tracking_off_for_this_role = $_REQUEST['classic_tracking_off_for_this_role'];
518
+
519
+
520
+
521
+
522
+
523
+ update_option('classic_property_id', $classic_property_id);
524
+
525
+ update_option('classic_in_footer', $classic_in_footer);
526
+
527
+ update_option('classic_plugin_switch', $classic_plugin_switch);
528
+
529
+ update_option('classic_tracking_off_for_role', $classic_tracking_off_for_role);
530
+
531
+ update_option('classic_tracking_off_for_this_role', $classic_tracking_off_for_this_role);
532
+
533
+ }
534
+
535
+ // Always die in functions echoing ajax content
536
+
537
+ die();
538
+
539
+ }
540
+
541
+ function save_google_custom_analytics_settings() {
542
+
543
+ // The $_REQUEST contains all the data sent via ajax
544
+
545
+ if ( isset($_REQUEST) ) {
546
+
547
+ $custom_in_footer = $_REQUEST['custom_in_footer'];
548
+
549
+ $custom_plugin_switch = $_REQUEST['custom_plugin_switch'];
550
+
551
+ $custom_web_property_id = $_REQUEST['custom_web_property_id'];
552
+
553
+ $custom_web_property_id = stripslashes($custom_web_property_id);
554
+
555
+ $custom_tracking_off_for_role = $_REQUEST['custom_tracking_off_for_role'];
556
+
557
+ $custom_tracking_off_for_this_role = $_REQUEST['custom_tracking_off_for_this_role'];
558
+
559
+
560
+
561
+
562
+
563
+ update_option('custom_in_footer', $custom_in_footer);
564
+
565
+ update_option('custom_plugin_switch', $custom_plugin_switch);
566
+
567
+ update_option('custom_web_property_id', $custom_web_property_id);
568
+
569
+ update_option('custom_tracking_off_for_role', $custom_tracking_off_for_role);
570
+
571
+ update_option('custom_tracking_off_for_this_role', $custom_tracking_off_for_this_role);
572
+
573
+ }
574
+
575
+ // Always die in functions echoing ajax content
576
+
577
+ die();
578
+
579
+ }
580
+
581
+
582
+
583
+
584
+
585
+ add_action( 'wp_ajax_save_google_universal_analytics_settings', 'save_google_universal_analytics_settings' );
586
+
587
+ add_action( 'wp_ajax_save_google_classic_analytics_settings', 'save_google_classic_analytics_settings' );
588
+
589
+ add_action( 'wp_ajax_save_google_custom_analytics_settings', 'save_google_custom_analytics_settings' );
590
+
591
+
592
+
593
+
594
+
595
  ?>
options.php CHANGED
@@ -1,73 +1,87 @@
1
- <div class="wrap">
2
- <h2>Google Universal Analytics</h2>
3
-
4
- <br />
5
- <div class="col-lg-6 row">
6
- <form class="form-horizontal" role="form" id="google-universal-options">
7
-
8
- <div class="form-group">
9
- <label for="web_property_id" class="col-sm-3 control-label">Status</label>
10
- <div class="col-sm-9">
11
- <input id="plugin_switch" type="checkbox" name="plugin_switch" <?php if(get_option('plugin_switch')=='on'): ?> checked="checked" <?php endif; ?>>
12
-
13
- </div>
14
- </div>
15
- <div class="form-group">
16
- <label for="web_property_id" class="col-sm-3 control-label">Tracking ID</label>
17
- <div class="col-sm-9">
18
- <input type="text" class="form-control" name="web_property_id" id="web_property_id" placeholder="Tracking code example: UA-­23710711-­7" value="<?php echo get_option('web_property_id'); ?>">
19
- <span class="error hide"><strong>Error! </strong> match your code with this forma: UA-41115660-1</span>
20
- </div>
21
- </div>
22
- <div class="form-group">
23
- <label for="web_property_id" class="col-sm-3 control-label"></label>
24
- <div class="col-sm-9">
25
- <i>Advanced settings:</i>
26
- </div>
27
- </div>
28
-
29
- <div class="form-group">
30
- <div class="col-sm-offset-3 col-sm-9">
31
- <div class="checkbox">
32
- <label>
33
- <input type="checkbox" name="in_footer" id="in_footer" <?php if(get_option('in_footer')=='on'): ?> checked="checked" <?php endif; ?>>
34
- Place code in footer </label>
35
- </div>
36
- </div>
37
- </div>
38
- <div class="form-group">
39
- <div class="col-sm-offset-3 col-sm-9">
40
- <div class="checkbox">
41
- <label>
42
- <input type="checkbox" name="track_links" id="track_links" <?php if(get_option('track_links')=='on'): ?> checked="checked" <?php endif; ?>>
43
- Track events (Downloads, Mailto & Outbound URLs) </label>
44
- </div>
45
- </div>
46
- </div>
47
- <div class="form-group">
48
- <div class="col-sm-offset-3 col-sm-9">
49
- <?php global $wp_roles;
50
- $roles = $wp_roles->get_names(); ?>
51
- <div class="checkbox">
52
- <label>
53
- <input type="checkbox" name="tracking_off_for_role" id="tracking_off_for_role" <?php if(get_option('tracking_off_for_role')=='on'): ?> checked="checked" <?php endif; ?>>
54
- Disable Tracking For <select id="tracking_off_for_this_role">
55
- <?php foreach($roles as $role) { ?>
56
- <option value="<?php echo $role;?>" <?php if(get_option('tracking_off_for_this_role')== $role){echo 'selected="selected"';} ?>><?php echo $role;?></option>
57
- <?php } ?>
58
- </select> </label>
59
- </div>
60
- </div>
61
- </div>
62
- <div class="form-group">
63
- <div class="col-sm-offset-3 col-sm-9">
64
- <input type="hidden" id="ajax_url" name="ajax_url" value="<?php echo admin_url('admin-ajax.php'); ?>" />
65
- <button type="button" class="btn btn-primary" id="save-gua-settings">Save Changes</button><span class="alert alert-success hide"><strong>Options Saved</strong></span>
66
- </div>
67
- </div>
68
- </form>
69
- </div>
70
- <div class="clearfix"></div>
71
- <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.1.2&utm_content=Google%20Universal%20Analytics&utm_campaign=WordPress%20plugins" title="Google Universal Analytics">OnlineAds.lt</a> </div>
72
- </div>
73
- </br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2>Google Universal Analytics</h2>
3
+ <br />
4
+ <div class="col-lg-6 row">
5
+ <form class="form-horizontal" role="form" id="google-universal-options">
6
+ <div class="form-group">
7
+ <label for="web_property_id" class="col-sm-3 control-label">Status</label>
8
+ <div class="col-sm-9">
9
+ <input id="plugin_switch" type="checkbox" name="plugin_switch" <?php if(get_option('plugin_switch')=='on'): ?> checked="checked" <?php endif; ?>>
10
+ </div>
11
+ </div>
12
+ <div class="form-group">
13
+ <label for="web_property_id" class="col-sm-3 control-label">Tracking ID</label>
14
+ <div class="col-sm-9">
15
+ <input type="text" class="form-control" name="web_property_id" id="web_property_id" placeholder="Tracking code example: UA-­23710711-­7" value="<?php echo get_option('web_property_id'); ?>">
16
+ <span class="error hide"><strong>Error! </strong> match your code with this forma: UA-41115660-1</span> </div>
17
+ </div>
18
+ <div class="form-group">
19
+ <label for="web_property_id" class="col-sm-3 control-label"></label>
20
+ <div class="col-sm-9"> <i>Advanced settings:</i> </div>
21
+ </div>
22
+ <div class="form-group">
23
+ <div class="col-sm-offset-3 col-sm-9">
24
+ <div class="checkbox">
25
+ <label>
26
+ <input type="checkbox" name="in_footer" id="in_footer" <?php if(get_option('in_footer')=='on'): ?> checked="checked" <?php endif; ?>>
27
+ Place code in footer </label>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <div class="form-group">
32
+ <div class="col-sm-offset-3 col-sm-9">
33
+ <div class="checkbox">
34
+ <label>
35
+ <input type="checkbox" name="track_links" id="track_links" <?php if(get_option('track_links')=='on'): ?> checked="checked" <?php endif; ?>>
36
+ Track events (Downloads, Mailto & Outbound URLs) </label>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <div class="form-group">
41
+ <div class="col-sm-offset-3 col-sm-9">
42
+ <div class="checkbox">
43
+ <label>
44
+ <input type="checkbox" name="enable_display" id="enable_display" <?php if(get_option('enable_display')=='on'): ?> checked="checked" <?php endif; ?>>
45
+ Enable Display Advertising <span style="color:green;">New!</span> </label>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ <div class="form-group">
50
+ <div class="col-sm-offset-3 col-sm-9">
51
+ <div class="checkbox">
52
+ <label>
53
+ <input type="checkbox" name="anonymize_ip" id="anonymize_ip" <?php if(get_option('anonymize_ip')=='on'): ?> checked="checked" <?php endif; ?>>
54
+ Anonymize IP <span style="color:green;">New!</span> </label>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ <div class="form-group">
59
+ <div class="col-sm-offset-3 col-sm-9">
60
+ <?php global $wp_roles;
61
+
62
+ $roles = $wp_roles->get_names(); ?>
63
+ <div class="checkbox">
64
+ <label>
65
+ <input type="checkbox" name="tracking_off_for_role" id="tracking_off_for_role" <?php if(get_option('tracking_off_for_role')=='on'): ?> checked="checked" <?php endif; ?>>
66
+ Disable Tracking For
67
+ <select id="tracking_off_for_this_role">
68
+ <?php foreach($roles as $role) { ?>
69
+ <option value="<?php echo $role;?>" <?php if(get_option('tracking_off_for_this_role')== $role){echo 'selected="selected"';} ?>><?php echo $role;?></option>
70
+ <?php } ?>
71
+ </select>
72
+ </label>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ <div class="form-group">
77
+ <div class="col-sm-offset-3 col-sm-9">
78
+ <input type="hidden" id="ajax_url" name="ajax_url" value="<?php echo admin_url('admin-ajax.php'); ?>" />
79
+ <button type="button" class="btn btn-primary" id="save-gua-settings">Save Changes</button>
80
+ <span class="alert alert-success hide"><strong>Options Saved</strong></span> </div>
81
+ </div>
82
+ </form>
83
+ </div>
84
+ <div class="clearfix"></div>
85
+ <div class="row col-lg-6">Have a question? Drop us a question at <a href="http://onlineads.lt/?utm_source=WordPress&utm_medium=Google%20Universal%20Analytics%202.2&utm_content=Google%20Universal%20Analytics&utm_campaign=WordPress%20plugins" title="Google Universal Analytics">OnlineAds.lt</a> </div>
86
+ </div>
87
+ </br>
readme.txt CHANGED
@@ -3,11 +3,11 @@ Contributors: audriusd
3
  Donate link: http://onlineads.lt/
4
  Tags: javascript, tracking, google, analytics, universal, statistics, google analytics, universal analytics, google universal analytics, classic, custom
5
  Requires at least: 3.0
6
- Tested up to: 3.8.1
7
- Stable tag: 2.1.2
8
  License: GPLv2 or later
9
 
10
- Adds the latest Google Universal Analytics JavaScript tracking code to your WordPress website. Event tracking is now available.
11
 
12
  == Description ==
13
 
@@ -62,6 +62,10 @@ Also, do not hesitate to contact us if you have any questions regarding [Google
62
 
63
  == Changelog ==
64
 
 
 
 
 
65
  = 2.1.2 =
66
  * jQuery bug fix.
67
 
@@ -96,6 +100,9 @@ Also, do not hesitate to contact us if you have any questions regarding [Google
96
 
97
  == Upgrade Notice ==
98
 
 
 
 
99
  = 2.1.2 =
100
  * Bug fix.
101
 
3
  Donate link: http://onlineads.lt/
4
  Tags: javascript, tracking, google, analytics, universal, statistics, google analytics, universal analytics, google universal analytics, classic, custom
5
  Requires at least: 3.0
6
+ Tested up to: 3.9
7
+ Stable tag: 2.2
8
  License: GPLv2 or later
9
 
10
+ Adds the latest Google Universal Analytics JavaScript tracking code to your WordPress website. Event tracking, Display Advertising (Remarketing) and IP Anonymization now available.
11
 
12
  == Description ==
13
 
62
 
63
  == Changelog ==
64
 
65
+ = 2.2 =
66
+ * Display Advertising feature added.
67
+ * IP Anonymization option is now available.
68
+
69
  = 2.1.2 =
70
  * jQuery bug fix.
71
 
100
 
101
  == Upgrade Notice ==
102
 
103
+ = 2.2 =
104
+ * Display Advertising and IP Anonymization options added.
105
+
106
  = 2.1.2 =
107
  * Bug fix.
108
 
tracking-code.php CHANGED
@@ -1,40 +1,88 @@
1
- <?php
2
- $web_property_id = get_option( 'web_property_id' );
3
- $track_links = get_option('track_links');
4
- $homeurl = get_option('home');
5
- $find = array( 'http://', 'https://', 'www.' );
6
- $replace = '';
7
- $homeurl = str_replace( $find, $replace, $homeurl );
8
- ?>
9
- <!-- Google Universal Analytics for WordPress -->
10
- <script>
11
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
12
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
13
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
14
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
15
-
16
- ga('create', '<?php echo $web_property_id; ?>', '<?php echo $homeurl; ?>');
17
- ga('send', 'pageview');
18
- </script>
19
- <?php if($track_links=='on'): ?>
20
- <script type="text/javascript">
21
- jQuery(document).ready(function(e) {
22
- jQuery('a').click(function(e) {
23
- var $this = jQuery(this);
24
- var href = $this.prop('href').split('?')[0];
25
- var ext = href.split('.').pop();
26
- if ('xls,xlsx,doc,docx,ppt,pot,pptx,pdf,pub,txt,zip,rar,tar,7z,exe,wma,mov,avi,wmv,wav,mp3,midi,csv,tsv,jar,psd,pdn,ai,pez,wwf'.split(',').indexOf(ext) !== -1) {
27
- ga('send', 'event', 'Download', ext, href);
28
- }
29
- if (href.toLowerCase().indexOf('mailto:') === 0) {
30
- ga('send', 'event', 'Mailto', href.substr(7));
31
-
32
- }
33
- if ((this.protocol === 'http:' || this.protocol === 'https:') && this.hostname.indexOf(document.location.hostname) === -1) {
34
- ga('send', 'event', 'Outbound', this.hostname, this.pathname);
35
- }
36
-
37
- });
38
- });
39
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  <?php endif;
1
+ <?php
2
+
3
+ $web_property_id = get_option( 'web_property_id' );
4
+
5
+ $track_links = get_option('track_links');
6
+
7
+ $enable_display = get_option('enable_display');
8
+
9
+ $anonymize_ip = get_option('anonymize_ip');
10
+
11
+ $homeurl = get_option('home');
12
+
13
+ $find = array( 'http://', 'https://', 'www.' );
14
+
15
+ $replace = '';
16
+
17
+ $homeurl = str_replace( $find, $replace, $homeurl );
18
+
19
+ ?>
20
+
21
+ <!-- Google Universal Analytics for WordPress -->
22
+
23
+ <script>
24
+
25
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
26
+
27
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
28
+
29
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
30
+
31
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
32
+
33
+
34
+
35
+ ga('create', '<?php echo $web_property_id; ?>', '<?php echo $homeurl; ?>');
36
+ <?php if($anonymize_ip=='on'): ?>
37
+ ga('set', 'anonymizeIp', true);
38
+ <?php endif; ?>
39
+ <?php if($enable_display=='on'): ?>
40
+ ga('require', 'displayfeatures');
41
+ <?php endif; ?>
42
+ ga('send', 'pageview');
43
+
44
+ </script>
45
+
46
+ <?php if($track_links=='on'): ?>
47
+
48
+ <script type="text/javascript">
49
+
50
+ jQuery(document).ready(function(e) {
51
+
52
+ jQuery('a').click(function(e) {
53
+
54
+ var $this = jQuery(this);
55
+
56
+ var href = $this.prop('href').split('?')[0];
57
+
58
+ var ext = href.split('.').pop();
59
+
60
+ if ('xls,xlsx,doc,docx,ppt,pot,pptx,pdf,pub,txt,zip,rar,tar,7z,exe,wma,mov,avi,wmv,wav,mp3,midi,csv,tsv,jar,psd,pdn,ai,pez,wwf'.split(',').indexOf(ext) !== -1) {
61
+
62
+ ga('send', 'event', 'Download', ext, href);
63
+
64
+ }
65
+
66
+ if (href.toLowerCase().indexOf('mailto:') === 0) {
67
+
68
+ ga('send', 'event', 'Mailto', href.substr(7));
69
+
70
+
71
+
72
+ }
73
+
74
+ if ((this.protocol === 'http:' || this.protocol === 'https:') && this.hostname.indexOf(document.location.hostname) === -1) {
75
+
76
+ ga('send', 'event', 'Outbound', this.hostname, this.pathname);
77
+
78
+ }
79
+
80
+
81
+
82
+ });
83
+
84
+ });
85
+
86
+ </script>
87
+
88
  <?php endif;