WP Google Analytics Events - Version 2.0

Version Description

Download this release

Release Info

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

Code changes from version 1.9 to 2.0

Files changed (6) hide show
  1. css/style.css +11 -8
  2. ga-scroll-event.php +9 -8
  3. includes/admin.php +12 -3
  4. js/admin.js +14 -0
  5. js/ga-scroll-events.js +38 -23
  6. readme.txt +8 -5
css/style.css CHANGED
@@ -74,7 +74,6 @@
74
 
75
  .ga_events_sidebar li {
76
  list-style-type: none !important;
77
- color: #FFF;
78
  font-size: 14px;
79
  }
80
 
@@ -85,22 +84,26 @@
85
  .ga_events_sidebar th {
86
  text-align: center;
87
  font-size: 19px;
88
- background-color: #22636A;
89
  color: white !important;
90
  }
91
- .ga_events_sidebar .tfoot {
92
- background-color: #22636A;
93
- }
94
 
95
- .ga_events_sidebar .features {
96
- background-color: #7ACBA6;
97
- }
98
 
99
  .ga_events_sidebar form {
100
  background-color: #96D0B5;
101
  padding: 0px !important;
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
104
  .ga_events_sidebar form .form-content {
105
  padding: 10px 0 10px 3%;
106
  }
74
 
75
  .ga_events_sidebar li {
76
  list-style-type: none !important;
 
77
  font-size: 14px;
78
  }
79
 
84
  .ga_events_sidebar th {
85
  text-align: center;
86
  font-size: 19px;
87
+ background-color: #32373c;
88
  color: white !important;
89
  }
 
 
 
90
 
 
 
 
91
 
92
  .ga_events_sidebar form {
93
  background-color: #96D0B5;
94
  padding: 0px !important;
95
  }
96
 
97
+ .ga_events_sidebar .features td{
98
+ padding: 0px 10px !important;
99
+ }
100
+
101
+ .ga_events_sidebar .button-large {
102
+ font-size: 17px;
103
+ line-height: 30px;
104
+ height: 32px;
105
+ }
106
+
107
  .ga_events_sidebar form .form-content {
108
  padding: 10px 0 10px 3%;
109
  }
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.9
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
@@ -42,6 +42,7 @@ function ga_events_install() {
42
  'id' => '',
43
  'exclude_snippet' => '0',
44
  'universal' => '0',
 
45
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
46
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
47
  );
@@ -78,23 +79,24 @@ function ga_events_header() {
78
  $id = $options['id'];
79
  $domain = $_SERVER['SERVER_NAME'];
80
  if (!isset($options['exclude_snippet']) || $options['exclude_snippet'] != '1' ) {
81
- if (isset($options['universal']) && $options['universal']) {
82
- echo "<script>
83
  if (typeof ga === 'undefined') {
84
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
85
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
86
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
87
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
88
 
89
- ga('create','$id', '$domain');
90
  ga('send', 'pageview');
91
  }
92
- </script>";
93
  } else {
94
- echo "<script type='text/javascript'>
95
  if (typeof _gaq === 'undefined') {
96
  var _gaq = _gaq || [];
97
  _gaq.push(['_setAccount', '$id']);
 
98
  _gaq.push(['_setDomainName', '$domain']);
99
  _gaq.push(['_setAllowLinker', true]);
100
  _gaq.push(['_trackPageview']);
@@ -106,8 +108,7 @@ function ga_events_header() {
106
  })();
107
  }
108
 
109
-
110
- </script>";
111
  }
112
  }
113
  }
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: 2.0
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
42
  'id' => '',
43
  'exclude_snippet' => '0',
44
  'universal' => '0',
45
+ 'anonymizeip' => '0',
46
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
47
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
48
  );
79
  $id = $options['id'];
80
  $domain = $_SERVER['SERVER_NAME'];
81
  if (!isset($options['exclude_snippet']) || $options['exclude_snippet'] != '1' ) {
82
+ if (isset($options['universal']) && $options['universal']) { ?>
83
+ <script>
84
  if (typeof ga === 'undefined') {
85
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
86
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
87
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
88
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
89
 
90
+ <?php echo (isset($options['anonymizeip']) && $options['anonymizeip']) ? "ga('create','$id', '$domain', {anonymizeIp: true});" : "ga('create','$id', '$domain');";?>
91
  ga('send', 'pageview');
92
  }
93
+ </script> <?php
94
  } else {
95
+ ?> <script type='text/javascript'>
96
  if (typeof _gaq === 'undefined') {
97
  var _gaq = _gaq || [];
98
  _gaq.push(['_setAccount', '$id']);
99
+ <?php if (isset($options['anonymizeip']) && $options['anonymizeip']) echo "_gaq.push (['_gat._anonymizeIp'])"; ?>
100
  _gaq.push(['_setDomainName', '$domain']);
101
  _gaq.push(['_setAllowLinker', true]);
102
  _gaq.push(['_trackPageview']);
108
  })();
109
  }
110
 
111
+ </script> <?php
 
112
  }
113
  }
114
  }
includes/admin.php CHANGED
@@ -69,13 +69,13 @@ function ga_events_settings_page() {
69
  <div class="wrap ga_events_sidebar">
70
  <table class="form-table widefat" >
71
  <thead>
72
- <th>Upgrade to Pro</th>
73
  </thead>
74
  <tbody>
75
  <tr class="features">
76
  <td>
77
  <ul>
78
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>One Checkbox Link Tracking</strong></li>
79
  <li title="Dynamic Event Data"><i class="fa fa-check-square-o fa-lg"></i><strong>Placeholders</strong></li>
80
  <li><i class="fa fa-check-square-o fa-lg"></i><strong>YouTube Video Tracking</strong></li>
81
  <li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
@@ -88,7 +88,7 @@ function ga_events_settings_page() {
88
  <tr class="tfoot">
89
  <td>
90
  <div class="wpcta">
91
- <a class="btn btn-subscribe" target="_blank" href="https://wpflow.com/upgrade?utm_source=wpadm&utm_medium=banner&utm_content=side&utm_campaign=wpadmin
92
  ">
93
  <span class="btn-title ">
94
  Upgrade Now
@@ -151,6 +151,7 @@ function ga_events_admin_init() {
151
  add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
152
  add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
153
  add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
 
154
  add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events_scroll','ga_events_scroll_section');
155
  add_settings_field('ga_events_started', '','ga_events_setting_started','ga_events_started','ga_events_started_section');
156
  add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events_click','ga_events_click_section');
@@ -210,6 +211,13 @@ function ga_events_setting_uni_input() {
210
  echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
211
  }
212
 
 
 
 
 
 
 
 
213
  function ga_events_settings_download(){
214
  echo '<a class="button" href="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] .'&download=1">Export settings</a>';
215
  }
@@ -362,6 +370,7 @@ function ga_events_validate($form){
362
  $updated['id'] = $form['id'];
363
  $updated['exclude_snippet'] = $form['exclude_snippet'];
364
  $updated['universal'] = $form['universal'];
 
365
  }
366
 
367
  return $updated;
69
  <div class="wrap ga_events_sidebar">
70
  <table class="form-table widefat" >
71
  <thead>
72
+ <th>Need More Features?</th>
73
  </thead>
74
  <tbody>
75
  <tr class="features">
76
  <td>
77
  <ul>
78
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Link Tracking</strong></li>
79
  <li title="Dynamic Event Data"><i class="fa fa-check-square-o fa-lg"></i><strong>Placeholders</strong></li>
80
  <li><i class="fa fa-check-square-o fa-lg"></i><strong>YouTube Video Tracking</strong></li>
81
  <li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
88
  <tr class="tfoot">
89
  <td>
90
  <div class="wpcta">
91
+ <a class="button-primary button-large" target="_blank" href="https://wpflow.com/upgrade?utm_source=wpadm&utm_medium=banner&utm_content=side&utm_campaign=wpadmin
92
  ">
93
  <span class="btn-title ">
94
  Upgrade Now
151
  add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
152
  add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
153
  add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
154
+ add_settings_field('ga_events_anonymizeip', '','ga_events_setting_anon_input','ga_events','ga_events_main');
155
  add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events_scroll','ga_events_scroll_section');
156
  add_settings_field('ga_events_started', '','ga_events_setting_started','ga_events_started','ga_events_started_section');
157
  add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events_click','ga_events_click_section');
211
  echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
212
  }
213
 
214
+ function ga_events_setting_anon_input() {
215
+ $options = get_option('ga_events_options');
216
+ $id = $options['anonymizeip'];
217
+ echo "<label>IP Anonymization <i>(Requires Code Snippet)</i></label>";
218
+ echo "<span class='ga_intable'><input id='anonymizeip' name='ga_events_options[anonymizeip]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
219
+ }
220
+
221
  function ga_events_settings_download(){
222
  echo '<a class="button" href="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] .'&download=1">Export settings</a>';
223
  }
370
  $updated['id'] = $form['id'];
371
  $updated['exclude_snippet'] = $form['exclude_snippet'];
372
  $updated['universal'] = $form['universal'];
373
+ $updated['anonymizeip'] = $form['anonymizeip'];
374
  }
375
 
376
  return $updated;
js/admin.js CHANGED
@@ -12,3 +12,17 @@ jQuery('.popup').on('click',function(e){
12
  jQuery('.popup').slideUp();
13
  e.preventDefault();
14
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  jQuery('.popup').slideUp();
13
  e.preventDefault();
14
  });
15
+
16
+ if (jQuery('#snippet').is(":checked")) {
17
+ jQuery('#anonymizeip')[0].checked = false;
18
+ jQuery('#anonymizeip').attr("disabled", true);
19
+ }
20
+
21
+ jQuery('#snippet').change(function () {
22
+ if (this.checked) {
23
+ jQuery('#anonymizeip')[0].checked = false;
24
+ jQuery('#anonymizeip').attr("disabled", true);
25
+ } else {
26
+ jQuery('#anonymizeip').removeAttr("disabled");
27
+ }
28
+ });
js/ga-scroll-events.js CHANGED
@@ -13,38 +13,53 @@ var scroll_events = (function ($) {
13
  var scroll_elements = [];
14
  var click_elements = [];
15
  var universal = 0;
16
- var ga_element;
17
 
18
- var track_event = function (category, action, label, universal) {
19
  var event_category = !category ? '' : category;
20
  var event_action = !action ? '' : action;
21
  var event_label = !label ? '' : label;
22
- if (typeof ga_element === "undefined") {
23
- if (typeof ga !== 'undefined') {
24
- ga_element = ga;
25
- } else if (typeof _gaq !== 'undefined') {
 
 
 
26
  ga_element = _gaq;
27
- } else if (typeof __gaTracker === "function") {
28
- ga_element = __gaTracker;
29
- }
 
 
 
 
 
 
 
30
  }
31
- if (universal) {
32
- ga_element('send','event', category, action, label);
33
- } else {
34
- ga_element.push(['_trackEvent',category, action, label]);
35
  }
36
 
37
  };
38
 
39
- var click_event = function (event) {
40
- track_event(event.data.category, event.data.action, event.data.label, event.data.universal);
41
-
42
- if (event.currentTarget.hasOwnProperty('href')) {
43
- event.preventDefault();
44
- setTimeout(function () {
45
- window.location = event.currentTarget.href;
46
- }, 100);
47
- }
 
 
 
 
 
 
48
  };
49
 
50
  return {
@@ -69,7 +84,7 @@ var scroll_events = (function ($) {
69
  if (!scroll_elements[i].sent) {
70
  scroll_elements[i].offset = $(scroll_elements[i].select).offset();
71
  if (scroll_elements[i].offset && ga_scroll_top + ga_window >= scroll_elements[i].offset.top + $(scroll_elements[i].select).height()) {
72
- track_event(scroll_elements[i].category, scroll_elements[i].action, scroll_elements[i].label, universal);
73
  scroll_elements[i].sent = true;
74
  }
75
  }
13
  var scroll_elements = [];
14
  var click_elements = [];
15
  var universal = 0;
16
+ var ga_element;
17
 
18
+ var track_event = function (category, action, label, universal, bounce ){
19
  var event_category = !category ? '' : category;
20
  var event_action = !action ? '' : action;
21
  var event_label = !label ? '' : label;
22
+ var event_bounce = !bounce ? false : bounce;
23
+
24
+ if( typeof ga_element === "undefined" ){
25
+ if( typeof ga !== 'undefined' ){
26
+ ga_element = ga;
27
+ }
28
+ else if( typeof _gaq !== 'undefined' ){
29
  ga_element = _gaq;
30
+ }
31
+ else if( typeof __gaTracker === "function" ){
32
+ ga_element = __gaTracker;
33
+ }
34
+ }
35
+
36
+ if( universal ){
37
+ // ga_element('send','event', category, action, label);
38
+ ga_element('send','event', category, action, label, {'nonInteraction': event_bounce});
39
+
40
  }
41
+ else {
42
+ // ga_element.push(['_trackEvent',category, action, label]);
43
+ ga_element.push( ['_trackEvent',category, action, label, '', event_bounce] );
 
44
  }
45
 
46
  };
47
 
48
+ var click_event = function( event ){
49
+
50
+ track_event(event.data.category, event.data.action, event.data.label, event.data.universal, event.data.bounce);
51
+ var hasHref = event.currentTarget.href;
52
+ if (hasHref && hasHref !== "") {
53
+ event.preventDefault();
54
+ if (event.currentTarget.target === "_blank") {
55
+ var w = window.open('', '_blank');
56
+ w.location.href = event.currentTarget.href;
57
+ } else {
58
+ setTimeout(function () {
59
+ window.location = event.currentTarget.href;
60
+ }, 100);
61
+ }
62
+ }
63
  };
64
 
65
  return {
84
  if (!scroll_elements[i].sent) {
85
  scroll_elements[i].offset = $(scroll_elements[i].select).offset();
86
  if (scroll_elements[i].offset && ga_scroll_top + ga_window >= scroll_elements[i].offset.top + $(scroll_elements[i].select).height()) {
87
+ track_event(scroll_elements[i].category, scroll_elements[i].action, scroll_elements[i].label, universal, scroll_elements[i].bounce);
88
  scroll_elements[i].sent = true;
89
  }
90
  }
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
- Tags: analytics, google, events, ga
4
- Tested up to: 4.4
5
- Stable tag: 1.9
6
  License: GPLv2
7
  Requires at least: 3.0
8
 
9
- Track Events Google Analytics on your website - Enables you to send an event when a user Scrolls or Click an element on your website.
10
  == Description ==
11
  The WP Google Analytics Events plugin allows you to send events to Google Analytics for:
12
  1. A user scrolls to a point of interest on your site
@@ -38,8 +38,11 @@ http://www.youtube.com/watch?v=UP8mfuV9huI
38
  3. Plugin Scroll Settings screenshot-5.png
39
  2. Google Analytics real time events screenshot-2.png
40
  == Changelog ==
 
 
 
41
  = Version 1.9 =
42
- 1. Added the Non-Interaction Field
43
  = Version 1.7 =
44
  1. Import / Export ferature added
45
  = Version 1.6 =
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
+ Tags: analytics, google, events, ga, google analytics, tracking
4
+ Tested up to: 4.5
5
+ Stable tag: 2.0
6
  License: GPLv2
7
  Requires at least: 3.0
8
 
9
+ Track Google Analytics Events on your website - Enables you to send an event when a user Scrolls or Click an element on your website.
10
  == Description ==
11
  The WP Google Analytics Events plugin allows you to send events to Google Analytics for:
12
  1. A user scrolls to a point of interest on your site
38
  3. Plugin Scroll Settings screenshot-5.png
39
  2. Google Analytics real time events screenshot-2.png
40
  == Changelog ==
41
+ = Version 2.0 =
42
+ 1. IP Anonimization
43
+ 2. Link Issues
44
  = Version 1.9 =
45
+ 1. Added the Non-Interaction Field
46
  = Version 1.7 =
47
  1. Import / Export ferature added
48
  = Version 1.6 =