WP Google Analytics Events - Version 1.3

Version Description

Download this release

Release Info

Developer yuvalo
Plugin Icon 128x128 WP Google Analytics Events
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

Files changed (2) hide show
  1. ga-scroll-event.php +31 -18
  2. readme.txt +2 -2
ga-scroll-event.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Google Analytics Events
4
  Plugin URI: http://wpflow.com
5
  Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
6
- Version: 1.2
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
@@ -29,6 +29,7 @@ register_activation_hook( __FILE__, 'ga_events_install' );
29
  function ga_events_install() {
30
  $ga_events_options = array(
31
  'id' => '',
 
32
  'universal' => '0',
33
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
34
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
@@ -82,7 +83,7 @@ function ga_events_settings_page() {
82
  <tr class="tfoot">
83
  <td>
84
  <div class="wpcta">
85
- <a class="btn btn-subscribe" href="http://wpflow.com">
86
  <span class="btn-title ">
87
  Starting from
88
  <span class="btn-data">
@@ -135,6 +136,7 @@ function ga_events_admin_init() {
135
  register_setting('ga_events_options','ga_events_options','ga_events_validate');
136
  add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
137
  add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
 
138
  add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
139
  add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events','ga_events_main');
140
  add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events','ga_events_main');
@@ -155,6 +157,15 @@ function ga_events_setting_input() {
155
 
156
  }
157
 
 
 
 
 
 
 
 
 
 
158
  function ga_events_setting_uni_input() {
159
  $options = get_option('ga_events_options');
160
  $id = $options['universal'];
@@ -255,6 +266,7 @@ function ga_events_setting_sidebar(){
255
  function ga_events_validate($form){
256
  $updated = array();
257
  $updated['id'] = $form['id'];
 
258
  $updated['universal'] = $form['universal'];
259
 
260
  for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
@@ -298,7 +310,7 @@ function ga_events_header() {
298
  $options = get_option('ga_events_options');
299
  $id = $options['id'];
300
  $domain = $_SERVER['SERVER_NAME'];
301
-
302
  if (isset($options['universal']) && $options['universal']) {
303
  echo "<script>
304
  if (typeof ga === 'undefined') {
@@ -312,24 +324,25 @@ function ga_events_header() {
312
  }
313
  </script>";
314
  } else {
315
- echo "<script type='text/javascript'>
316
- if (typeof _gaq === 'undefined') {
317
- var _gaq = _gaq || [];
318
- _gaq.push(['_setAccount', '$id']);
319
- _gaq.push(['_setDomainName', '$domain']);
320
- _gaq.push(['_setAllowLinker', true]);
321
- _gaq.push(['_trackPageview']);
322
-
323
- (function() {
324
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
325
- ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
326
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
327
- })();
328
- }
329
 
330
 
331
  </script>";
332
  }
 
333
  }
334
 
335
  add_action( 'wp_footer', 'ga_events_footer', 100 );
@@ -399,4 +412,4 @@ function ga_events_get_selector($element) {
399
 
400
  }
401
 
402
- ?>
3
  Plugin Name: WP Google Analytics Events
4
  Plugin URI: http://wpflow.com
5
  Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
6
+ Version: 1.3
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
29
  function ga_events_install() {
30
  $ga_events_options = array(
31
  'id' => '',
32
+ 'exclude_snippet' => '0',
33
  'universal' => '0',
34
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
35
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
83
  <tr class="tfoot">
84
  <td>
85
  <div class="wpcta">
86
+ <a class="btn btn-subscribe" href="http://wpflow.com/upgrade/">
87
  <span class="btn-title ">
88
  Starting from
89
  <span class="btn-data">
136
  register_setting('ga_events_options','ga_events_options','ga_events_validate');
137
  add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
138
  add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
139
+ add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
140
  add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
141
  add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events','ga_events_main');
142
  add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events','ga_events_main');
157
 
158
  }
159
 
160
+
161
+ function ga_events_setting_snippet_input() {
162
+ $options = get_option('ga_events_options');
163
+ $id = $options['exclude_snippet'];
164
+ echo "<label>Don't add the GA tracking code</label>";
165
+ echo "<span class='ga_intable'><input id='snippet' name='ga_events_options[exclude_snippet]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
166
+
167
+ }
168
+
169
  function ga_events_setting_uni_input() {
170
  $options = get_option('ga_events_options');
171
  $id = $options['universal'];
266
  function ga_events_validate($form){
267
  $updated = array();
268
  $updated['id'] = $form['id'];
269
+ $updated['exclude_snippet'] = $form['exclude_snippet'];
270
  $updated['universal'] = $form['universal'];
271
 
272
  for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
310
  $options = get_option('ga_events_options');
311
  $id = $options['id'];
312
  $domain = $_SERVER['SERVER_NAME'];
313
+ if (!isset($options['exclude_snippet']) || $options['exclude_snippet'] != '1' ) {
314
  if (isset($options['universal']) && $options['universal']) {
315
  echo "<script>
316
  if (typeof ga === 'undefined') {
324
  }
325
  </script>";
326
  } else {
327
+ echo "<script type='text/javascript'>
328
+ if (typeof _gaq === 'undefined') {
329
+ var _gaq = _gaq || [];
330
+ _gaq.push(['_setAccount', '$id']);
331
+ _gaq.push(['_setDomainName', '$domain']);
332
+ _gaq.push(['_setAllowLinker', true]);
333
+ _gaq.push(['_trackPageview']);
334
+
335
+ (function() {
336
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
337
+ ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
338
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
339
+ })();
340
+ }
341
 
342
 
343
  </script>";
344
  }
345
+ }
346
  }
347
 
348
  add_action( 'wp_footer', 'ga_events_footer', 100 );
412
 
413
  }
414
 
415
+ ?>
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
  Tags: analytics, google, events, ga
4
- Tested up to: 3.8.1
5
- Stable tag: 1.2
6
  License: GPLv2
7
  Requires at least: 3.0
8
 
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
  Tags: analytics, google, events, ga
4
+ Tested up to: 4.0
5
+ Stable tag: 1.3
6
  License: GPLv2
7
  Requires at least: 3.0
8