Version Description
- Released 2018-11-07
- Removed some checks for better event tracking
- Updating filter for partial entries
- Tested successfully with WordPress 5.0 Beta 3
- Tested successfully with Gravity Forms 2.4 Beta 2
Download this release
Release Info
Developer | ronalfy |
Plugin | Event Tracking for Gravity Forms |
Version | 2.3.2 |
Comparing to | |
See all releases |
Code changes from version 2.3.0 to 2.3.2
- README.txt +12 -2
- gravity-forms-event-tracking.php +1 -1
- includes/GFGAET_Partial_Entries.php +2 -2
- includes/GFGAET_Submission_Feeds.php +55 -67
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:
|
6 |
-
Stable tag: 2.3.
|
7 |
Requires PHP: 5.6
|
8 |
Donate link: https://mediaron.com/give/
|
9 |
License: GPLv2 or later
|
@@ -126,6 +126,13 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
= 2.3.0 =
|
130 |
* Released 2018-10-03
|
131 |
* Added support for the Partial Entries add-on.
|
@@ -269,6 +276,9 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
269 |
|
270 |
== Upgrade Notice ==
|
271 |
|
|
|
|
|
|
|
272 |
= 2.3.0 =
|
273 |
Added support for the Partial Entries add-on.
|
274 |
|
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.2
|
7 |
Requires PHP: 5.6
|
8 |
Donate link: https://mediaron.com/give/
|
9 |
License: GPLv2 or later
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 2.3.2 =
|
130 |
+
* Released 2018-11-07
|
131 |
+
* Removed some checks for better event tracking
|
132 |
+
* Updating filter for partial entries
|
133 |
+
* Tested successfully with WordPress 5.0 Beta 3
|
134 |
+
* Tested successfully with Gravity Forms 2.4 Beta 2
|
135 |
+
|
136 |
= 2.3.0 =
|
137 |
* Released 2018-10-03
|
138 |
* Added support for the Partial Entries add-on.
|
276 |
|
277 |
== Upgrade Notice ==
|
278 |
|
279 |
+
= 2.3.2 =
|
280 |
+
Removed some checks for better event tracking. Updating filter for partial entries.
|
281 |
+
|
282 |
= 2.3.0 =
|
283 |
Added support for the Partial Entries add-on.
|
284 |
|
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.
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
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.2
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
includes/GFGAET_Partial_Entries.php
CHANGED
@@ -121,7 +121,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
121 |
* @param string $value Gravity Forms Field value
|
122 |
* @param string label Label of the form entry
|
123 |
*/
|
124 |
-
$event_label = apply_filters( '
|
125 |
|
126 |
/**
|
127 |
* Filter: gform_partial_event_value
|
@@ -136,7 +136,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
136 |
* @param string $value Gravity Forms Field value
|
137 |
* @param string label Label of the form entry
|
138 |
*/
|
139 |
-
$event_value = apply_filters( '
|
140 |
|
141 |
// Let's set up the measurement protocol
|
142 |
$ua_code = GFGAET::get_ua_code();
|
121 |
* @param string $value Gravity Forms Field value
|
122 |
* @param string label Label of the form entry
|
123 |
*/
|
124 |
+
$event_label = apply_filters( 'gform_partial_event_label', $event_label, $form, $partial_entry, $value, $label );
|
125 |
|
126 |
/**
|
127 |
* Filter: gform_partial_event_value
|
136 |
* @param string $value Gravity Forms Field value
|
137 |
* @param string label Label of the form entry
|
138 |
*/
|
139 |
+
$event_value = apply_filters( 'gform_partial_event_value', $event_value, $form, $partial_entry, $value, $label );
|
140 |
|
141 |
// Let's set up the measurement protocol
|
142 |
$ua_code = GFGAET::get_ua_code();
|
includes/GFGAET_Submission_Feeds.php
CHANGED
@@ -269,7 +269,8 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
|
269 |
*/
|
270 |
$google_analytics_codes = apply_filters( 'gform_ua_ids', $google_analytics_codes, $form, $entry );
|
271 |
|
272 |
-
|
|
|
273 |
|
274 |
$event = new GFGAET_Measurement_Protocol();
|
275 |
$event->init();
|
@@ -351,61 +352,56 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
|
351 |
<?php
|
352 |
foreach( $google_analytics_codes as $ua_code ) {
|
353 |
?>
|
354 |
-
var feed_submission = sessionStorage.getItem('feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>');
|
355 |
-
if ( null == feed_submission ) {
|
356 |
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
}
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
if ( typeof( console ) == 'object' ) {
|
366 |
-
console.log('
|
|
|
367 |
}
|
368 |
-
|
369 |
-
|
370 |
-
// Check for GA from Monster Insights Plugin
|
371 |
-
if ( typeof window.parent.ga == 'undefined' ) {
|
372 |
-
console.log('ga not found');
|
373 |
-
if ( typeof window.parent.__gaTracker != 'undefined' ) {
|
374 |
-
if( typeof( console ) == 'object' ) {
|
375 |
-
console.log('monster insights found');
|
376 |
-
}
|
377 |
-
window.parent.ga = window.parent.__gaTracker;
|
378 |
-
}
|
379 |
}
|
380 |
if ( typeof( console ) == 'object' ) {
|
381 |
-
console.log('
|
|
|
|
|
382 |
}
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
ga_tracker = '<?php echo esc_js( GFGAET::get_ua_tracker() ); ?>';
|
390 |
-
if ( typeof( console ) == 'object' ) {
|
391 |
-
console.log( 'tracker name' );
|
392 |
-
console.log( ga_tracker );
|
393 |
-
}
|
394 |
-
if( ga_tracker.length > 0 ) {
|
395 |
-
ga_send = ga_tracker + '.' + ga_send;
|
396 |
-
}
|
397 |
-
if ( typeof( console ) == 'object' ) {
|
398 |
-
console.log( 'send command' );
|
399 |
-
console.log( ga_send );
|
400 |
-
console.log( <?php echo $event_value; ?> );
|
401 |
-
}
|
402 |
-
|
403 |
-
// Use that tracker
|
404 |
-
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 ) . "'"; } ?>);
|
405 |
-
|
406 |
-
sessionStorage.setItem('feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>', true );
|
407 |
-
}
|
408 |
-
}
|
409 |
}
|
410 |
|
411 |
<?php
|
@@ -418,18 +414,14 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
|
418 |
} elseif ( GFGAET::is_gtm_only() ) {
|
419 |
?>
|
420 |
<script>
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
'GFEntryData':<?php echo json_encode( $entry ); ?>
|
430 |
-
});
|
431 |
-
sessionStorage.setItem("feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>", "true");
|
432 |
-
}
|
433 |
}
|
434 |
</script>
|
435 |
<?php
|
@@ -528,14 +520,10 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
|
528 |
if ( GFGAET::is_matomo_js_only() ) {
|
529 |
?>
|
530 |
<script>
|
531 |
-
|
532 |
-
if ( null == matomo_feed_submission ) {
|
533 |
-
if ( typeof window.parent._paq != 'undefined' ) {
|
534 |
|
535 |
-
|
536 |
|
537 |
-
sessionStorage.setItem('matomo_feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>', true );
|
538 |
-
}
|
539 |
}
|
540 |
</script>
|
541 |
<?php
|
269 |
*/
|
270 |
$google_analytics_codes = apply_filters( 'gform_ua_ids', $google_analytics_codes, $form, $entry );
|
271 |
|
272 |
+
if ( !is_array( $google_analytics_codes ) || empty( $google_analytics_codes ) ) return;
|
273 |
+
$google_analytics_codes = array_unique($google_analytics_codes);
|
274 |
|
275 |
$event = new GFGAET_Measurement_Protocol();
|
276 |
$event->init();
|
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 ) ); } ?>
|
362 |
+
}
|
363 |
+
);
|
364 |
+
if ( typeof( console ) == 'object' ) {
|
365 |
+
console.log('gtag tried');
|
366 |
+
}
|
367 |
+
} else {
|
368 |
+
// Check for GA from Monster Insights Plugin
|
369 |
+
if ( typeof window.parent.ga == 'undefined' ) {
|
370 |
+
console.log('ga not found');
|
371 |
+
if ( typeof window.parent.__gaTracker != 'undefined' ) {
|
372 |
+
if( typeof( console ) == 'object' ) {
|
373 |
+
console.log('monster insights found');
|
374 |
}
|
375 |
+
window.parent.ga = window.parent.__gaTracker;
|
376 |
+
}
|
377 |
+
}
|
378 |
+
if ( typeof( console ) == 'object' ) {
|
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' );
|
390 |
+
console.log( ga_tracker );
|
391 |
}
|
392 |
+
if( ga_tracker.length > 0 ) {
|
393 |
+
ga_send = ga_tracker + '.' + ga_send;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
}
|
395 |
if ( typeof( console ) == 'object' ) {
|
396 |
+
console.log( 'send command' );
|
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
|
414 |
} elseif ( GFGAET::is_gtm_only() ) {
|
415 |
?>
|
416 |
<script>
|
417 |
+
if ( typeof( window.parent.dataLayer ) != 'undefined' ) {
|
418 |
+
window.parent.dataLayer.push({'event': 'GFTrackEvent',
|
419 |
+
'GFTrackCategory':'<?php echo esc_js( $event_category ); ?>',
|
420 |
+
'GFTrackAction':'<?php echo esc_js( $event_action ); ?>',
|
421 |
+
'GFTrackLabel':'<?php echo esc_js( $event_label ); ?>',
|
422 |
+
'GFTrackValue': <?php echo absint( $event_value ); ?>,
|
423 |
+
'GFEntryData':<?php echo json_encode( $entry ); ?>
|
424 |
+
});
|
|
|
|
|
|
|
|
|
425 |
}
|
426 |
</script>
|
427 |
<?php
|
520 |
if ( GFGAET::is_matomo_js_only() ) {
|
521 |
?>
|
522 |
<script>
|
523 |
+
if ( typeof window.parent._paq != 'undefined' ) {
|
|
|
|
|
524 |
|
525 |
+
window.parent._paq.push(['trackEvent', '<?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 ) . "'"; } ?>]);
|
526 |
|
|
|
|
|
527 |
}
|
528 |
</script>
|
529 |
<?php
|