Event Tracking for Gravity Forms - Version 2.3.8

Version Description

  • Released 2019-03-24
  • Added support for noninteractive hits
Download this release

Release Info

Developer ronalfy
Plugin Icon 128x128 Event Tracking for Gravity Forms
Version 2.3.8
Comparing to
See all releases

Code changes from version 2.3.5 to 2.3.8

README.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: ronalfy, bigwing, nmarks, kzeni
3
  Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
4
  Requires at least:4.0
5
- Tested up to: 5.0
6
- Stable tag: 2.3.5
7
  Requires PHP: 5.6
8
  Donate link: https://mediaron.com/give/
9
  License: GPLv2 or later
@@ -28,7 +28,7 @@ Also supports:
28
  Looking for help setting things up? [Read Our Setup Guide](https://mediaron.com/event-tracking-for-gravity-forms/)
29
 
30
  = Minimum Requirements =
31
- - Gravity Forms 2.0+
32
  - Google Analytics Universal Analytics
33
  - Google Tag Manager (optional)
34
  - Matomo (formerly Piwik) account (optional)
@@ -50,7 +50,7 @@ Development happens on <a href="https://github.com/ronalfy/wordpress-gravity-for
50
  == Installation ==
51
 
52
  = Minimum Requirements =
53
- - Gravity Forms 2.0+
54
 
55
  = Using The WordPress Dashboard =
56
 
@@ -126,6 +126,10 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
126
 
127
  == Changelog ==
128
 
 
 
 
 
129
  = 2.3.5 =
130
  * Released 2018-11-14
131
  * Added pagination settings to Gravity Forms form settings screen for per-form override
@@ -147,7 +151,7 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
147
 
148
  = 2.2.2 =
149
  * Released 2018-08-27
150
- * Adding support for gtag
151
 
152
  = 2.2.1 =
153
  * Released 2018-08-23
@@ -160,7 +164,7 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
160
  * Enhancement: Can now set event values to pagination <a href="https://github.com/ronalfy/wordpress-gravity-forms-event-tracking#gform_pagination_event_value">using filters</a>
161
  * Note: Google only accepts integer values, so total fields and such will be rounded up or down when viewing your conversion reports
162
 
163
- = 2.1.1 =
164
  * Released 2018-06-22
165
  * Documentation update
166
 
@@ -280,10 +284,13 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
280
 
281
  == Upgrade Notice ==
282
 
 
 
 
283
  = 2.3.5 =
284
  Added pagination settings to Gravity Forms form settings screen for per-form override
285
 
286
- = 2.3.2 =
287
  Removed some checks for better event tracking. Updating filter for partial entries.
288
 
289
  = 2.3.0 =
2
  Contributors: ronalfy, bigwing, nmarks, kzeni
3
  Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
4
  Requires at least:4.0
5
+ Tested up to: 5.2
6
+ Stable tag: 2.3.8
7
  Requires PHP: 5.6
8
  Donate link: https://mediaron.com/give/
9
  License: GPLv2 or later
28
  Looking for help setting things up? [Read Our Setup Guide](https://mediaron.com/event-tracking-for-gravity-forms/)
29
 
30
  = Minimum Requirements =
31
+ - Gravity Forms 2.4
32
  - Google Analytics Universal Analytics
33
  - Google Tag Manager (optional)
34
  - Matomo (formerly Piwik) account (optional)
50
  == Installation ==
51
 
52
  = Minimum Requirements =
53
+ - Gravity Forms 2.4+
54
 
55
  = Using The WordPress Dashboard =
56
 
126
 
127
  == Changelog ==
128
 
129
+ = 2.3.8 =
130
+ * Released 2019-03-24
131
+ * Added support for noninteractive hits
132
+
133
  = 2.3.5 =
134
  * Released 2018-11-14
135
  * Added pagination settings to Gravity Forms form settings screen for per-form override
151
 
152
  = 2.2.2 =
153
  * Released 2018-08-27
154
+ * Adding support for gtag
155
 
156
  = 2.2.1 =
157
  * Released 2018-08-23
164
  * Enhancement: Can now set event values to pagination <a href="https://github.com/ronalfy/wordpress-gravity-forms-event-tracking#gform_pagination_event_value">using filters</a>
165
  * Note: Google only accepts integer values, so total fields and such will be rounded up or down when viewing your conversion reports
166
 
167
+ = 2.1.1 =
168
  * Released 2018-06-22
169
  * Documentation update
170
 
284
 
285
  == Upgrade Notice ==
286
 
287
+ = 2.3.8 =
288
+ Added support for noninteractive hits.
289
+
290
  = 2.3.5 =
291
  Added pagination settings to Gravity Forms form settings screen for per-form override
292
 
293
+ = 2.3.2 =
294
  Removed some checks for better event tracking. Updating filter for partial entries.
295
 
296
  = 2.3.0 =
gravity-forms-event-tracking.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Gravity Forms Event Tracking
4
  * Plugin URI: https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking/
5
  * Description: Add event tracking to your Gravity Forms with ease using Google Analytics, Tag Manager, or Matomo (formerly Piwik).
6
- * Version: 2.3.5
7
  * Author: Ronald Huereca
8
  * Author URI: https://mediaron.com
9
  * Text Domain: gravity-forms-google-analytics-event-tracking
@@ -152,7 +152,7 @@ class GFGAET {
152
  }
153
  return false;
154
  }
155
-
156
  /**
157
  * Get the Google Analytics Tracker
158
  *
@@ -167,6 +167,20 @@ class GFGAET {
167
  return $tracker;
168
  }
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  /**
171
  * Checks whether Google Analytics mode is activated for sending events.
172
  *
3
  * Plugin Name: Gravity Forms Event Tracking
4
  * Plugin URI: https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking/
5
  * Description: Add event tracking to your Gravity Forms with ease using Google Analytics, Tag Manager, or Matomo (formerly Piwik).
6
+ * Version: 2.3.8
7
  * Author: Ronald Huereca
8
  * Author URI: https://mediaron.com
9
  * Text Domain: gravity-forms-google-analytics-event-tracking
152
  }
153
  return false;
154
  }
155
+
156
  /**
157
  * Get the Google Analytics Tracker
158
  *
167
  return $tracker;
168
  }
169
 
170
+ /**
171
+ * Get the Google Analytics Tracker
172
+ *
173
+ * @since 2.3.8
174
+ * @return string Returns a custom tracker or empty string if not set
175
+ */
176
+ public static function get_interactive_hit_tracker() {
177
+ $gravity_forms_add_on_settings = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
178
+
179
+ $interactive_hit = isset( $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua_interaction_hit' ] ) ? $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua_interaction_hit' ] : 'interactive_off';
180
+
181
+ return $interactive_hit;
182
+ }
183
+
184
  /**
185
  * Checks whether Google Analytics mode is activated for sending events.
186
  *
includes/GFGAET_Submission_Feeds.php CHANGED
@@ -347,15 +347,23 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
347
 
348
  if ( GFGAET::is_ga_only() ) {
349
  $count = 1;
 
 
 
 
 
 
 
350
  ?>
351
  <script>
352
  <?php
353
  foreach( $google_analytics_codes as $ua_code ) {
354
  ?>
355
-
356
  // Check for gtab implementation
357
  if( typeof window.parent.gtag != 'undefined' ) {
358
  window.parent.gtag( 'event', '<?php echo esc_js( $event_action ); ?>', {
 
359
  'event_category': '<?php echo esc_js( $event_category ); ?>',
360
  'event_label': '<?php echo esc_js( $event_label ); ?>'
361
  <?php if ( 0 !== $event_value && !empty( $event_value ) ) { echo sprintf( ",'value': '%s'", esc_js( $event_value ) ); } ?>
@@ -379,11 +387,11 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
379
  console.log('try window.parent.ga');
380
  }
381
  if ( typeof window.parent.ga != 'undefined' ) {
382
-
383
  var ga_tracker = '';
384
  var ga_send = 'send';
385
  // Try to get original UA code from third-party plugins or tag manager
386
-
387
  ga_tracker = '<?php echo esc_js( GFGAET::get_ua_tracker() ); ?>';
388
  if ( typeof( console ) == 'object' ) {
389
  console.log( 'tracker name' );
@@ -397,11 +405,13 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
397
  console.log( ga_send );
398
  console.log( '<?php echo $event_value; ?>' );
399
  }
400
-
401
  // Use that tracker
402
- window.parent.ga( ga_send, 'event', '<?php echo esc_js( $event_category ); ?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>'<?php if ( 0 !== $event_value && !empty( $event_value ) ) { echo ',' . "'" . esc_js( $event_value ) . "'"; } ?>);
 
 
403
 
404
- }
405
  }
406
 
407
  <?php
@@ -434,7 +444,7 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
434
  }
435
  }
436
 
437
-
438
  }
439
 
440
  /**
347
 
348
  if ( GFGAET::is_ga_only() ) {
349
  $count = 1;
350
+ $is_interactive_hit = 'false';
351
+ $interactive_hit = GFGAET::get_interactive_hit_tracker();
352
+ if( 'interactive_off' == $interactive_hit ) {
353
+ $is_interactive_hit = 'false';
354
+ } else {
355
+ $is_interactive_hit = 'true';
356
+ }
357
  ?>
358
  <script>
359
  <?php
360
  foreach( $google_analytics_codes as $ua_code ) {
361
  ?>
362
+
363
  // Check for gtab implementation
364
  if( typeof window.parent.gtag != 'undefined' ) {
365
  window.parent.gtag( 'event', '<?php echo esc_js( $event_action ); ?>', {
366
+ nonInteraction: <?php echo esc_js( $is_interactive_hit ); ?>,
367
  'event_category': '<?php echo esc_js( $event_category ); ?>',
368
  'event_label': '<?php echo esc_js( $event_label ); ?>'
369
  <?php if ( 0 !== $event_value && !empty( $event_value ) ) { echo sprintf( ",'value': '%s'", esc_js( $event_value ) ); } ?>
387
  console.log('try window.parent.ga');
388
  }
389
  if ( typeof window.parent.ga != 'undefined' ) {
390
+
391
  var ga_tracker = '';
392
  var ga_send = 'send';
393
  // Try to get original UA code from third-party plugins or tag manager
394
+
395
  ga_tracker = '<?php echo esc_js( GFGAET::get_ua_tracker() ); ?>';
396
  if ( typeof( console ) == 'object' ) {
397
  console.log( 'tracker name' );
405
  console.log( ga_send );
406
  console.log( '<?php echo $event_value; ?>' );
407
  }
408
+
409
  // Use that tracker
410
+ window.parent.ga( ga_send, 'event', '<?php echo esc_js( $event_category ); ?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>'<?php if ( 0 !== $event_value && !empty( $event_value ) ) { echo ',' . "'" . esc_js( $event_value ) . "'"; } ?>, {
411
+ nonInteraction: <?php echo esc_js( $is_interactive_hit ); ?>
412
+ });
413
 
414
+ }
415
  }
416
 
417
  <?php
444
  }
445
  }
446
 
447
+
448
  }
449
 
450
  /**
includes/GFGAET_UA.php CHANGED
@@ -70,6 +70,28 @@ class GFGAET_UA extends GFAddOn {
70
  'type' => 'text',
71
  'class' => 'small',
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ),
74
  array(
75
  'type' => 'radio',
70
  'type' => 'text',
71
  'class' => 'small',
72
 
73
+ ),
74
+ array(
75
+ 'name' => 'gravity_forms_event_tracking_ua_interaction_hit',
76
+ 'tooltip' => __( 'Enter whether the hits are interactive or not.', 'gravity-forms-google-analytics-event-tracking' ),
77
+ 'label' => __( 'Non-interactive hits', 'gravity-forms-google-analytics-event-tracking' ),
78
+ 'type' => 'radio',
79
+ 'default_value' => 'interactive_on',
80
+ 'choices' => array(
81
+ array(
82
+ 'name' => 'interactive_on',
83
+ 'tooltip' => esc_html__( 'Interaction hits are on', 'gravity-forms-google-analytics-event-tracking' ),
84
+ 'label' => esc_html__( 'Turn on Interactive Hits', 'gravity-forms-google-analytics-event-tracking' ),
85
+ 'value' => 'interactive_on'
86
+ ),
87
+ array(
88
+ 'name' => 'interactive_off',
89
+ 'tooltip' => esc_html__( 'Interaction hits are off', 'gravity-forms-google-analytics-event-tracking' ),
90
+ 'label' => esc_html__( 'Turn off Interactive Hits', 'gravity-forms-google-analytics-event-tracking' ),
91
+ 'value' => 'interactive_off'
92
+ ),
93
+ ),
94
+
95
  ),
96
  array(
97
  'type' => 'radio',