Version Description
- Released 2022-12-02
- Minifying UTM script for performance.
- Only load UTM script when UTM variables are present or a form is present.
Download this release
Release Info
| Developer | ronalfy |
| Plugin | |
| Version | 2.4.14 |
| Comparing to | |
| See all releases | |
Code changes from version 2.4.12 to 2.4.14
- README.txt +8 -3
- gravity-forms-event-tracking.php +2 -2
- includes/GFGAET_Partial_Entries.php +2 -1
- includes/GFGAET_Submission_Feeds.php +48 -13
- js/utm-tag-manager.min.js +2 -0
README.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: ronalfy, bigwing, nmarks, kzeni
|
|
| 3 |
Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
|
| 4 |
Requires at least: 5.5
|
| 5 |
Tested up to: 6.1
|
| 6 |
-
Stable tag: 2.4.
|
| 7 |
Requires PHP: 5.6
|
| 8 |
Donate link: https://github.com/mediaron
|
| 9 |
License: GPLv2 or later
|
|
@@ -145,6 +145,11 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
| 145 |
|
| 146 |
== Changelog ==
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
= 2.4.12 =
|
| 149 |
* Released 2022-11-09
|
| 150 |
* Updating Google Analytics Add-on banners.
|
|
@@ -369,5 +374,5 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
| 369 |
|
| 370 |
== Upgrade Notice ==
|
| 371 |
|
| 372 |
-
= 2.4.
|
| 373 |
-
|
| 3 |
Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
|
| 4 |
Requires at least: 5.5
|
| 5 |
Tested up to: 6.1
|
| 6 |
+
Stable tag: 2.4.14
|
| 7 |
Requires PHP: 5.6
|
| 8 |
Donate link: https://github.com/mediaron
|
| 9 |
License: GPLv2 or later
|
| 145 |
|
| 146 |
== Changelog ==
|
| 147 |
|
| 148 |
+
= 2.4.14 =
|
| 149 |
+
* Released 2022-12-02
|
| 150 |
+
* Minifying UTM script for performance.
|
| 151 |
+
* Only load UTM script when UTM variables are present or a form is present.
|
| 152 |
+
|
| 153 |
= 2.4.12 =
|
| 154 |
* Released 2022-11-09
|
| 155 |
* Updating Google Analytics Add-on banners.
|
| 374 |
|
| 375 |
== Upgrade Notice ==
|
| 376 |
|
| 377 |
+
= 2.4.14 =
|
| 378 |
+
Minifying GTM/UTM script and only load when UTM variables or a form is present.
|
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
|
| 6 |
-
* Version: 2.4.
|
| 7 |
* Author: Ronald Huereca
|
| 8 |
* Author URI: https://mediaron.com
|
| 9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
|
@@ -19,7 +19,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
| 19 |
}
|
| 20 |
|
| 21 |
define( 'GFGAET_MIN_GFORMS_VERSION', '2.2.0' );
|
| 22 |
-
define( 'GFGAET_VERSION', '2.4.
|
| 23 |
define( 'GFGAET_FILE', __FILE__ );
|
| 24 |
|
| 25 |
class GFGAET {
|
| 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
|
| 6 |
+
* Version: 2.4.14
|
| 7 |
* Author: Ronald Huereca
|
| 8 |
* Author URI: https://mediaron.com
|
| 9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
| 19 |
}
|
| 20 |
|
| 21 |
define( 'GFGAET_MIN_GFORMS_VERSION', '2.2.0' );
|
| 22 |
+
define( 'GFGAET_VERSION', '2.4.14' );
|
| 23 |
define( 'GFGAET_FILE', __FILE__ );
|
| 24 |
|
| 25 |
class GFGAET {
|
includes/GFGAET_Partial_Entries.php
CHANGED
|
@@ -201,8 +201,9 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
| 201 |
* Finally, map this value based on the $field_id
|
| 202 |
* and $input['id'].
|
| 203 |
*/
|
|
|
|
| 204 |
$mapping[ $field_id ] = array(
|
| 205 |
-
'value' => $
|
| 206 |
'label' => $field['label'],
|
| 207 |
'event_category' => $event_category,
|
| 208 |
'event_action' => $event_action,
|
| 201 |
* Finally, map this value based on the $field_id
|
| 202 |
* and $input['id'].
|
| 203 |
*/
|
| 204 |
+
$value = $entry[ $input['id'] ] ?? '';
|
| 205 |
$mapping[ $field_id ] = array(
|
| 206 |
+
'value' => $value,
|
| 207 |
'label' => $field['label'],
|
| 208 |
'event_category' => $event_category,
|
| 209 |
'event_action' => $event_action,
|
includes/GFGAET_Submission_Feeds.php
CHANGED
|
@@ -91,14 +91,14 @@ class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
|
| 91 |
*/
|
| 92 |
public function add_settings_link( $links ) {
|
| 93 |
|
| 94 |
-
$settings_url = admin_url( 'admin.php?page=gf_settings&subview=GFGAET_UA');
|
| 95 |
if ( current_user_can( 'manage_options' ) ) {
|
| 96 |
$options_link = sprintf( '<a href="%s">%s</a>', esc_url( $settings_url ), _x( 'Settings', 'Gravity Forms Event Tracking Settings page', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 97 |
$links[] = $options_link;
|
| 98 |
}
|
| 99 |
$docs_link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( 'https://mediaron.com/event-tracking-for-gravity-forms/?utm_source=wordpress_plugins_page&utm_medium=documentation&utm_campaign=event_tracking' ), _x( 'Documentation', 'Gravity Forms Event Tracking Documentation page', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 100 |
|
| 101 |
-
|
| 102 |
$links[] = $docs_link;
|
| 103 |
$links[] = $beta_link;
|
| 104 |
|
|
@@ -407,17 +407,52 @@ gtag('config', '<?php echo esc_js( $ga_code ); ?>');
|
|
| 407 |
$ua_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
|
| 408 |
if ( isset( $ua_options['gravity_forms_event_tracking_gtm_utm_vars'] ) ) {
|
| 409 |
if ( 'utm_on' === $ua_options['gravity_forms_event_tracking_gtm_utm_vars'] ) {
|
| 410 |
-
|
| 411 |
-
'
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
|
|
|
| 416 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
| 418 |
}
|
| 419 |
}
|
| 420 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
/**
|
| 422 |
* Outputs admin scripts to handle form submission in back-end.
|
| 423 |
*
|
|
@@ -1116,11 +1151,11 @@ gtag('config', '<?php echo esc_js( $ga_code ); ?>');
|
|
| 1116 |
*/
|
| 1117 |
public function feed_settings_fields() {
|
| 1118 |
$ga_id_placeholder = $this->get_ga_id();
|
| 1119 |
-
$ua_options
|
| 1120 |
-
$beta_notification = rgar( $ua_options, 'beta_notification');
|
| 1121 |
-
$beta_field
|
| 1122 |
-
'name'
|
| 1123 |
-
'type'
|
| 1124 |
);
|
| 1125 |
return array(
|
| 1126 |
array(
|
| 91 |
*/
|
| 92 |
public function add_settings_link( $links ) {
|
| 93 |
|
| 94 |
+
$settings_url = admin_url( 'admin.php?page=gf_settings&subview=GFGAET_UA' );
|
| 95 |
if ( current_user_can( 'manage_options' ) ) {
|
| 96 |
$options_link = sprintf( '<a href="%s">%s</a>', esc_url( $settings_url ), _x( 'Settings', 'Gravity Forms Event Tracking Settings page', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 97 |
$links[] = $options_link;
|
| 98 |
}
|
| 99 |
$docs_link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( 'https://mediaron.com/event-tracking-for-gravity-forms/?utm_source=wordpress_plugins_page&utm_medium=documentation&utm_campaign=event_tracking' ), _x( 'Documentation', 'Gravity Forms Event Tracking Documentation page', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 100 |
|
| 101 |
+
$beta_link = sprintf( '<a href="%s" target="_blank" style="color: green; font-weight: 700;">%s</a>', esc_url( 'https://www.gravityforms.com/add-ons/google-analytics/' ), _x( 'Get the Google Analytics Add-on', 'Gravity Forms Google Analytics Page', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 102 |
$links[] = $docs_link;
|
| 103 |
$links[] = $beta_link;
|
| 104 |
|
| 407 |
$ua_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
|
| 408 |
if ( isset( $ua_options['gravity_forms_event_tracking_gtm_utm_vars'] ) ) {
|
| 409 |
if ( 'utm_on' === $ua_options['gravity_forms_event_tracking_gtm_utm_vars'] ) {
|
| 410 |
+
$utm_vars = array(
|
| 411 |
+
'utm_id',
|
| 412 |
+
'utm_source',
|
| 413 |
+
'utm_medium',
|
| 414 |
+
'utm_campaign',
|
| 415 |
+
'utm_term',
|
| 416 |
+
'utm_content',
|
| 417 |
);
|
| 418 |
+
$can_load_utm_script = false;
|
| 419 |
+
foreach ( $utm_vars as $utm_var ) {
|
| 420 |
+
if ( isset( $_GET[ $utm_var ] ) ) { // phpcs:ignore
|
| 421 |
+
$can_load_utm_script = true;
|
| 422 |
+
break;
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
if ( $can_load_utm_script || $this->has_form() ) {
|
| 426 |
+
$script_location = GFGAET::get_plugin_url( '/js/utm-tag-manager.min.js' );
|
| 427 |
+
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
| 428 |
+
$script_location = GFGAET::get_plugin_url( '/js/utm-tag-manager.js' );
|
| 429 |
+
}
|
| 430 |
+
wp_enqueue_script(
|
| 431 |
+
'gforms_event_tracking_utm_gtm',
|
| 432 |
+
$script_location,
|
| 433 |
+
array( 'jquery', 'wp-ajax-response' ),
|
| 434 |
+
$this->_version,
|
| 435 |
+
true
|
| 436 |
+
);
|
| 437 |
+
}
|
| 438 |
}
|
| 439 |
}
|
| 440 |
}
|
| 441 |
|
| 442 |
+
/**
|
| 443 |
+
* Determines if a page has a form on it.
|
| 444 |
+
*
|
| 445 |
+
* @return bool Whether post/page has gravity form.
|
| 446 |
+
*/
|
| 447 |
+
private function has_form() {
|
| 448 |
+
if ( ! class_exists( 'GFCommon' ) || ! is_singular() ) {
|
| 449 |
+
return;
|
| 450 |
+
}
|
| 451 |
+
require_once GFCommon::get_base_path() . '/form_display.php';
|
| 452 |
+
GFFormDisplay::parse_forms( get_queried_object()->post_content, $forms, $blocks );
|
| 453 |
+
return ! empty( $forms );
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
/**
|
| 457 |
* Outputs admin scripts to handle form submission in back-end.
|
| 458 |
*
|
| 1151 |
*/
|
| 1152 |
public function feed_settings_fields() {
|
| 1153 |
$ga_id_placeholder = $this->get_ga_id();
|
| 1154 |
+
$ua_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
|
| 1155 |
+
$beta_notification = rgar( $ua_options, 'beta_notification' );
|
| 1156 |
+
$beta_field = array(
|
| 1157 |
+
'name' => 'gravityforms_ga',
|
| 1158 |
+
'type' => $beta_notification === 'on' || rgblank( $beta_notification ) ? 'gforms_beta_cta' : 'hidden',
|
| 1159 |
);
|
| 1160 |
return array(
|
| 1161 |
array(
|
js/utm-tag-manager.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
| 1 |
+
(function(GF_EventTracking_UTM_Tag_Manager,$){jQuery(document).ready(function(){var hrefObject=wpAjax.unserialize(window.location.href);if(typeof hrefObject.utm_source!=="undefined"){var utmSource=decodeURIComponent(hrefObject.utm_source);var utmMedium="",utmCampaign="",utmTerm="",utmContent="";if(typeof hrefObject.utm_medium!=="undefined")utmMedium=decodeURIComponent(hrefObject.utm_medium);if(typeof hrefObject.utm_campaign!=="undefined")utmCampaign=decodeURIComponent(hrefObject.utm_campaign);if(typeof hrefObject.utm_term!==
|
| 2 |
+
"undefined")utmTerm=decodeURIComponent(hrefObject.utm_term);if(typeof hrefObject.utm_content!=="undefined")utmContent=decodeURIComponent(hrefObject.utm_content);var utmObject={source:utmSource,medium:utmMedium,campaign:utmCampaign,term:utmTerm,content:utmContent};localStorage.setItem("googleAnalyticsUTM",JSON.stringify(utmObject))}})})(window.GF_EventTracking_UTM_Tag_Manager=window.GF_EventTracking_UTM_Tag_Manager||{},jQuery);
|
