Version Description
- Released 2019-05-16
- Fixing pagination settings for the form with correct default values
- Fixed PHP 7.3 error with partial entries add-on showing incorrect offset
Download this release
Release Info
Developer | ronalfy |
Plugin | Event Tracking for Gravity Forms |
Version | 2.3.9 |
Comparing to | |
See all releases |
Code changes from version 2.3.8 to 2.3.9
- README.txt +9 -28
- gravity-forms-event-tracking.php +1 -1
- includes/GFGAET_Pagination.php +7 -1
- includes/GFGAET_Pagination_Settings.php +3 -3
- includes/GFGAET_Partial_Entries.php +27 -27
README.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Event Tracking for Gravity Forms ===
|
2 |
Contributors: ronalfy, bigwing, nmarks, kzeni
|
3 |
Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
|
4 |
-
Requires at least:4.
|
5 |
Tested up to: 5.2
|
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,11 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
|
|
|
|
|
|
|
|
|
|
129 |
= 2.3.8 =
|
130 |
* Released 2019-03-24
|
131 |
* Added support for noninteractive hits
|
@@ -284,29 +289,5 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
284 |
|
285 |
== Upgrade Notice ==
|
286 |
|
287 |
-
= 2.3.
|
288 |
-
|
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 =
|
297 |
-
Added support for the Partial Entries add-on.
|
298 |
-
|
299 |
-
= 2.2.4 =
|
300 |
-
Adding support for custom trackers
|
301 |
-
|
302 |
-
= 2.2.2 =
|
303 |
-
Adding support for gtag
|
304 |
-
|
305 |
-
= 2.2.1 =
|
306 |
-
Bug fix: Blank event values were being sent in Google Analytics mode, which resulted in failed conversions. Please double-check your conversions after you update.
|
307 |
-
|
308 |
-
= 2.2.0 =
|
309 |
-
Event values can now be sent using the Measurement Protocol, Google Analytics, Google Tag Manager, and Matomo. Please double-check your conversions after you update.
|
310 |
-
|
311 |
-
= 2.1.0 =
|
312 |
-
Enhancement: Added Matomo (formerly Piwik) support
|
1 |
=== Event Tracking for Gravity Forms ===
|
2 |
Contributors: ronalfy, bigwing, nmarks, kzeni
|
3 |
Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
|
4 |
+
Requires at least:4.9
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 2.3.9
|
7 |
Requires PHP: 5.6
|
8 |
Donate link: https://mediaron.com/give/
|
9 |
License: GPLv2 or later
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 2.3.9 =
|
130 |
+
* Released 2019-05-16
|
131 |
+
* Fixing pagination settings for the form with correct default values
|
132 |
+
* Fixed PHP 7.3 error with partial entries add-on showing incorrect offset
|
133 |
+
|
134 |
= 2.3.8 =
|
135 |
* Released 2019-03-24
|
136 |
* Added support for noninteractive hits
|
289 |
|
290 |
== Upgrade Notice ==
|
291 |
|
292 |
+
= 2.3.9 =
|
293 |
+
Fixing pagination settings for the form with correct default values. Fixed PHP 7.3 error with partial entries add-on showing incorrect offset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.9
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
includes/GFGAET_Pagination.php
CHANGED
@@ -103,6 +103,9 @@ class GFGAET_Pagination {
|
|
103 |
if ( isset( $form['pagination_label'] ) ) {
|
104 |
$pagination_label = trim( $form['pagination_label'] );
|
105 |
if( ! empty( $pagination_label ) ) {
|
|
|
|
|
|
|
106 |
$event_label = $pagination_label;
|
107 |
}
|
108 |
}
|
@@ -129,7 +132,7 @@ class GFGAET_Pagination {
|
|
129 |
}
|
130 |
// Value is rounded up (Google likes integers only) before given an absolute value
|
131 |
$event_value = absint( round( GFCommon::to_number( apply_filters( 'gform_pagination_event_value', $event_value, $form, $source_page_number, $current_page_number ) ) ) );
|
132 |
-
|
133 |
// Set environmental variables for the measurement protocol
|
134 |
$event->set_event_category( $event_category );
|
135 |
$event->set_event_action( $event_action );
|
@@ -261,6 +264,9 @@ class GFGAET_Pagination {
|
|
261 |
if ( isset( $form['pagination_label'] ) ) {
|
262 |
$pagination_label = trim( $form['pagination_label'] );
|
263 |
if( ! empty( $pagination_label ) ) {
|
|
|
|
|
|
|
264 |
$event_label = $pagination_label;
|
265 |
}
|
266 |
}
|
103 |
if ( isset( $form['pagination_label'] ) ) {
|
104 |
$pagination_label = trim( $form['pagination_label'] );
|
105 |
if( ! empty( $pagination_label ) ) {
|
106 |
+
$pagination_label = str_replace( '{form_title}', esc_html( $form['title'] ), $pagination_label );
|
107 |
+
$pagination_label = str_replace( '{source_page_number}', absint( $source_page_number ), $pagination_label );
|
108 |
+
$pagination_label = str_replace( '{current_page_number}', absint( $current_page_number ), $pagination_label );
|
109 |
$event_label = $pagination_label;
|
110 |
}
|
111 |
}
|
132 |
}
|
133 |
// Value is rounded up (Google likes integers only) before given an absolute value
|
134 |
$event_value = absint( round( GFCommon::to_number( apply_filters( 'gform_pagination_event_value', $event_value, $form, $source_page_number, $current_page_number ) ) ) );
|
135 |
+
|
136 |
// Set environmental variables for the measurement protocol
|
137 |
$event->set_event_category( $event_category );
|
138 |
$event->set_event_action( $event_action );
|
264 |
if ( isset( $form['pagination_label'] ) ) {
|
265 |
$pagination_label = trim( $form['pagination_label'] );
|
266 |
if( ! empty( $pagination_label ) ) {
|
267 |
+
$pagination_label = str_replace( '{form_title}', esc_html( $form['title'] ), $pagination_label );
|
268 |
+
$pagination_label = str_replace( '{source_page_number}', absint( $source_page_number ), $pagination_label );
|
269 |
+
$pagination_label = str_replace( '{current_page_number}', absint( $current_page_number ), $pagination_label );
|
270 |
$event_label = $pagination_label;
|
271 |
}
|
272 |
}
|
includes/GFGAET_Pagination_Settings.php
CHANGED
@@ -43,7 +43,7 @@ class GFGAET_Pagination_Settings extends GFAddOn {
|
|
43 |
* @since 2.3.5
|
44 |
*
|
45 |
* @param array $form The form
|
46 |
-
*
|
47 |
* @return array Updated form values
|
48 |
*/
|
49 |
public function save_pagination_settings( $form ) {
|
@@ -61,7 +61,7 @@ class GFGAET_Pagination_Settings extends GFAddOn {
|
|
61 |
*
|
62 |
* @param array $settings The form settings
|
63 |
* @param array $form The form
|
64 |
-
*
|
65 |
* @return array Updated form settings
|
66 |
*/
|
67 |
public function add_pagination_form_settings( $settings, $form ) {
|
@@ -74,7 +74,7 @@ class GFGAET_Pagination_Settings extends GFAddOn {
|
|
74 |
<strong>%s:</strong> %s<br />
|
75 |
<strong>%s:</strong> 0
|
76 |
</th>
|
77 |
-
</tr>', __( 'If left blank, the following values are used:', 'gravity-forms-google-analytics-event-tracking' ), __( 'Category', 'gravity-forms-google-analytics-event-tracking' ), __( 'Action', 'gravity-forms-google-analytics-event-tracking' ), __( 'Label', 'gravity-forms-google-analytics-event-tracking' ), __( '{
|
78 |
$settings[ __( 'Pagination Event Tracking', 'gravity-forms-google-analytics-event-tracking' ) ]['pagination_category'] = sprintf( '
|
79 |
<tr>
|
80 |
<th><label for="pagination_category">%s</label></th>
|
43 |
* @since 2.3.5
|
44 |
*
|
45 |
* @param array $form The form
|
46 |
+
*
|
47 |
* @return array Updated form values
|
48 |
*/
|
49 |
public function save_pagination_settings( $form ) {
|
61 |
*
|
62 |
* @param array $settings The form settings
|
63 |
* @param array $form The form
|
64 |
+
*
|
65 |
* @return array Updated form settings
|
66 |
*/
|
67 |
public function add_pagination_form_settings( $settings, $form ) {
|
74 |
<strong>%s:</strong> %s<br />
|
75 |
<strong>%s:</strong> 0
|
76 |
</th>
|
77 |
+
</tr>', __( 'If left blank, the following values are used:', 'gravity-forms-google-analytics-event-tracking' ), __( 'Category', 'gravity-forms-google-analytics-event-tracking' ), __( 'Action', 'gravity-forms-google-analytics-event-tracking' ), __( 'Label', 'gravity-forms-google-analytics-event-tracking' ), __( '{form_title}::{source_page_number}::{current_page_number}', 'gravity-forms-google-analytics-event-tracking' ), __( 'Value', 'gravity-forms-google-analytics-event-tracking' ) );
|
78 |
$settings[ __( 'Pagination Event Tracking', 'gravity-forms-google-analytics-event-tracking' ) ]['pagination_category'] = sprintf( '
|
79 |
<tr>
|
80 |
<th><label for="pagination_category">%s</label></th>
|
includes/GFGAET_Partial_Entries.php
CHANGED
@@ -22,7 +22,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
22 |
* Returns an instance of this class, and stores it in the $_instance property.
|
23 |
*
|
24 |
* @since 2.3.0
|
25 |
-
*
|
26 |
* @return object $_instance An instance of this class.
|
27 |
*/
|
28 |
public static function get_instance() {
|
@@ -37,7 +37,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
37 |
* Initailizes partial entries updated and saved state
|
38 |
*
|
39 |
* @since 2.3.0
|
40 |
-
*
|
41 |
* @return void
|
42 |
*/
|
43 |
public function init() {
|
@@ -45,15 +45,15 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
45 |
add_action( 'gform_partialentries_post_entry_saved', array( $this, 'partial_entry_saved' ), 10, 2 );
|
46 |
add_action( 'gform_partialentries_post_entry_updated', array( $this, 'partial_entry_saved' ), 10, 2 );
|
47 |
}
|
48 |
-
|
49 |
/**
|
50 |
* Sends the event via the measurement protocol
|
51 |
*
|
52 |
* @since 2.3.0
|
53 |
-
*
|
54 |
* @param array $partial_entry The partial entry to be parsed
|
55 |
* @param array $form The form to be parsed
|
56 |
-
*
|
57 |
* @return void
|
58 |
*/
|
59 |
public function partial_entry_saved( $partial_entry, $form ) {
|
@@ -64,7 +64,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
64 |
// Get defaults
|
65 |
$value = $gform_values['value'];
|
66 |
$label = strtolower( 'label: ' . $gform_values['label'] ) . " EntryID: {$partial_entry['id']}";
|
67 |
-
|
68 |
// Get category/action/label
|
69 |
$event_category = trim( $gform_values['event_category'] );
|
70 |
$event_action = ( empty( $gform_values['event_action'] ) ? 'partial' : trim( $gform_values['event_action'] ) );
|
@@ -155,20 +155,20 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
155 |
* Map fields for parsing
|
156 |
*
|
157 |
* @since 2.3.0
|
158 |
-
*
|
159 |
* @param array $entry The partial entry to be parsed
|
160 |
* @param array $form The form to be parsed
|
161 |
-
*
|
162 |
* @return array Mapped fields
|
163 |
*/
|
164 |
public function get_mapped_fields( $entry, $form ) {
|
165 |
$mapping = array();
|
166 |
-
|
167 |
foreach ( $form['fields'] as $field ) {
|
168 |
if ( ! isset( $field['id'] ) || ! $field['id'] ) {
|
169 |
continue;
|
170 |
}
|
171 |
-
|
172 |
// Explode field IDs.
|
173 |
$field_ids = explode( ',', $field['id'] );
|
174 |
$field_ids = array_map( 'trim', $field_ids );
|
@@ -180,21 +180,21 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
180 |
$event_action = GFCommon::replace_variables( $event_action, $form, $entry );
|
181 |
$event_label = GFCommon::replace_variables( $event_label, $form, $entry );
|
182 |
$event_value = GFCommon::replace_variables( $event_value, $form, $entry );
|
183 |
-
|
184 |
// We have a complex field, with multiple inputs.
|
185 |
if ( ! empty( $field['inputs'] ) ) {
|
186 |
foreach ( $field['inputs'] as $input ) {
|
187 |
if ( isset( $input['isHidden'] ) && $input['isHidden'] ) {
|
188 |
continue;
|
189 |
}
|
190 |
-
|
191 |
$field_id = array_shift( $field_ids );
|
192 |
-
|
193 |
// If $field_id is empty, don't map this input.
|
194 |
if ( ! $field_id ) {
|
195 |
continue;
|
196 |
}
|
197 |
-
|
198 |
/*
|
199 |
* Finally, map this value based on the $field_id
|
200 |
* and $input['id'].
|
@@ -210,8 +210,8 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
210 |
}
|
211 |
} else {
|
212 |
$mapping[ $field_ids[0] ] = array(
|
213 |
-
'value' => $entry[ $field['id'] ],
|
214 |
-
'label' => $field['label'],
|
215 |
'event_category' => $event_category,
|
216 |
'event_action' => $event_action,
|
217 |
'event_label' => $event_label,
|
@@ -219,7 +219,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
219 |
);
|
220 |
}
|
221 |
}
|
222 |
-
|
223 |
return $mapping;
|
224 |
}
|
225 |
|
@@ -227,7 +227,7 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
227 |
* Set up actions and filters for the add-on
|
228 |
*
|
229 |
* @since 2.3.0
|
230 |
-
*
|
231 |
* @return void
|
232 |
*/
|
233 |
public function init_admin() {
|
@@ -241,9 +241,9 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
241 |
* Set up tooltips for the advanced settings
|
242 |
*
|
243 |
* @since 2.3.0
|
244 |
-
*
|
245 |
* @param array $tooltips Array of tooltips
|
246 |
-
*
|
247 |
* @return array Updated Tooltips
|
248 |
*/
|
249 |
public function add_tooltips( $tooltips ) {
|
@@ -258,13 +258,13 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
258 |
* Ensure the add-on only works with Partial Entries
|
259 |
*
|
260 |
* @since 2.3.0
|
261 |
-
*
|
262 |
* @return array Minimum requirements
|
263 |
*/
|
264 |
public function minimum_requirements() {
|
265 |
return array(
|
266 |
// Require other add-ons to be present.
|
267 |
-
'add-ons' => array(
|
268 |
'gravityformspartialentries',
|
269 |
),
|
270 |
);
|
@@ -272,9 +272,9 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
272 |
|
273 |
/**
|
274 |
* Allow advanced options to be visible and map values to their parameters
|
275 |
-
*
|
276 |
-
* @since 2.3.0
|
277 |
-
*
|
278 |
* @return void
|
279 |
*/
|
280 |
public function editor_script() {
|
@@ -302,10 +302,10 @@ class GFGAET_Partial_Entries extends GFAddOn {
|
|
302 |
* Set up advanced settings
|
303 |
*
|
304 |
* @since 2.3.0
|
305 |
-
*
|
306 |
* @param int $position The position of the advanced settings
|
307 |
* @param int $form_id The form ID to perform the action on
|
308 |
-
*
|
309 |
* @return string HTML for advanced settings
|
310 |
*/
|
311 |
public function advanced_settings( $position, $form_id ) {
|
22 |
* Returns an instance of this class, and stores it in the $_instance property.
|
23 |
*
|
24 |
* @since 2.3.0
|
25 |
+
*
|
26 |
* @return object $_instance An instance of this class.
|
27 |
*/
|
28 |
public static function get_instance() {
|
37 |
* Initailizes partial entries updated and saved state
|
38 |
*
|
39 |
* @since 2.3.0
|
40 |
+
*
|
41 |
* @return void
|
42 |
*/
|
43 |
public function init() {
|
45 |
add_action( 'gform_partialentries_post_entry_saved', array( $this, 'partial_entry_saved' ), 10, 2 );
|
46 |
add_action( 'gform_partialentries_post_entry_updated', array( $this, 'partial_entry_saved' ), 10, 2 );
|
47 |
}
|
48 |
+
|
49 |
/**
|
50 |
* Sends the event via the measurement protocol
|
51 |
*
|
52 |
* @since 2.3.0
|
53 |
+
*
|
54 |
* @param array $partial_entry The partial entry to be parsed
|
55 |
* @param array $form The form to be parsed
|
56 |
+
*
|
57 |
* @return void
|
58 |
*/
|
59 |
public function partial_entry_saved( $partial_entry, $form ) {
|
64 |
// Get defaults
|
65 |
$value = $gform_values['value'];
|
66 |
$label = strtolower( 'label: ' . $gform_values['label'] ) . " EntryID: {$partial_entry['id']}";
|
67 |
+
|
68 |
// Get category/action/label
|
69 |
$event_category = trim( $gform_values['event_category'] );
|
70 |
$event_action = ( empty( $gform_values['event_action'] ) ? 'partial' : trim( $gform_values['event_action'] ) );
|
155 |
* Map fields for parsing
|
156 |
*
|
157 |
* @since 2.3.0
|
158 |
+
*
|
159 |
* @param array $entry The partial entry to be parsed
|
160 |
* @param array $form The form to be parsed
|
161 |
+
*
|
162 |
* @return array Mapped fields
|
163 |
*/
|
164 |
public function get_mapped_fields( $entry, $form ) {
|
165 |
$mapping = array();
|
166 |
+
|
167 |
foreach ( $form['fields'] as $field ) {
|
168 |
if ( ! isset( $field['id'] ) || ! $field['id'] ) {
|
169 |
continue;
|
170 |
}
|
171 |
+
|
172 |
// Explode field IDs.
|
173 |
$field_ids = explode( ',', $field['id'] );
|
174 |
$field_ids = array_map( 'trim', $field_ids );
|
180 |
$event_action = GFCommon::replace_variables( $event_action, $form, $entry );
|
181 |
$event_label = GFCommon::replace_variables( $event_label, $form, $entry );
|
182 |
$event_value = GFCommon::replace_variables( $event_value, $form, $entry );
|
183 |
+
|
184 |
// We have a complex field, with multiple inputs.
|
185 |
if ( ! empty( $field['inputs'] ) ) {
|
186 |
foreach ( $field['inputs'] as $input ) {
|
187 |
if ( isset( $input['isHidden'] ) && $input['isHidden'] ) {
|
188 |
continue;
|
189 |
}
|
190 |
+
|
191 |
$field_id = array_shift( $field_ids );
|
192 |
+
|
193 |
// If $field_id is empty, don't map this input.
|
194 |
if ( ! $field_id ) {
|
195 |
continue;
|
196 |
}
|
197 |
+
|
198 |
/*
|
199 |
* Finally, map this value based on the $field_id
|
200 |
* and $input['id'].
|
210 |
}
|
211 |
} else {
|
212 |
$mapping[ $field_ids[0] ] = array(
|
213 |
+
'value' => ( isset( $entry[ $field['id'] ] ) ) ? $entry[ $field['id'] ] : '',
|
214 |
+
'label' => ( isset( $field['label'] ) ) ? $field['label'] : '',
|
215 |
'event_category' => $event_category,
|
216 |
'event_action' => $event_action,
|
217 |
'event_label' => $event_label,
|
219 |
);
|
220 |
}
|
221 |
}
|
222 |
+
|
223 |
return $mapping;
|
224 |
}
|
225 |
|
227 |
* Set up actions and filters for the add-on
|
228 |
*
|
229 |
* @since 2.3.0
|
230 |
+
*
|
231 |
* @return void
|
232 |
*/
|
233 |
public function init_admin() {
|
241 |
* Set up tooltips for the advanced settings
|
242 |
*
|
243 |
* @since 2.3.0
|
244 |
+
*
|
245 |
* @param array $tooltips Array of tooltips
|
246 |
+
*
|
247 |
* @return array Updated Tooltips
|
248 |
*/
|
249 |
public function add_tooltips( $tooltips ) {
|
258 |
* Ensure the add-on only works with Partial Entries
|
259 |
*
|
260 |
* @since 2.3.0
|
261 |
+
*
|
262 |
* @return array Minimum requirements
|
263 |
*/
|
264 |
public function minimum_requirements() {
|
265 |
return array(
|
266 |
// Require other add-ons to be present.
|
267 |
+
'add-ons' => array(
|
268 |
'gravityformspartialentries',
|
269 |
),
|
270 |
);
|
272 |
|
273 |
/**
|
274 |
* Allow advanced options to be visible and map values to their parameters
|
275 |
+
*
|
276 |
+
* @since 2.3.0
|
277 |
+
*
|
278 |
* @return void
|
279 |
*/
|
280 |
public function editor_script() {
|
302 |
* Set up advanced settings
|
303 |
*
|
304 |
* @since 2.3.0
|
305 |
+
*
|
306 |
* @param int $position The position of the advanced settings
|
307 |
* @param int $form_id The form ID to perform the action on
|
308 |
+
*
|
309 |
* @return string HTML for advanced settings
|
310 |
*/
|
311 |
public function advanced_settings( $position, $form_id ) {
|