Version Description
- Released 2018-10-03
- Added support for the Partial Entries add-on.
Download this release
Release Info
Developer | ronalfy |
Plugin | Event Tracking for Gravity Forms |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.3.0
- README.txt +18 -1
- gravity-forms-event-tracking.php +6 -1
- includes/GFGAET_Measurement_Protocol.php +0 -1
- includes/GFGAET_Partial_Entries.php +344 -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:4.0
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 2.
|
7 |
Requires PHP: 5.6
|
8 |
Donate link: https://mediaron.com/give/
|
9 |
License: GPLv2 or later
|
@@ -104,6 +104,15 @@ Yes, the video above shows you how. Please note that values can be integers only
|
|
104 |
|
105 |
Yes, check out <a href="https://github.com/ronalfy/wordpress-gravity-forms-event-tracking#gform_pagination_event_action">our filters on GitHub</a>.
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
= Are there any filters/hooks? =
|
108 |
|
109 |
Check out the documentation on [github](https://github.com/ronalfy/wordpress-gravity-forms-event-tracking)
|
@@ -113,9 +122,14 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
113 |
1. The Gravity Forms setting screen where you setup your event tracking.
|
114 |
2. The form settings feed list.
|
115 |
3. The feed settings page
|
|
|
116 |
|
117 |
== Changelog ==
|
118 |
|
|
|
|
|
|
|
|
|
119 |
= 2.2.4 =
|
120 |
* Released 2018-10-02
|
121 |
* Adding support for custom trackers
|
@@ -255,6 +269,9 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
255 |
|
256 |
== Upgrade Notice ==
|
257 |
|
|
|
|
|
|
|
258 |
= 2.2.4 =
|
259 |
Adding support for custom trackers
|
260 |
|
3 |
Tags: gravity forms, google analytics, google tag manager, matomo, piwik, event tracking
|
4 |
Requires at least:4.0
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 2.3.0
|
7 |
Requires PHP: 5.6
|
8 |
Donate link: https://mediaron.com/give/
|
9 |
License: GPLv2 or later
|
104 |
|
105 |
Yes, check out <a href="https://github.com/ronalfy/wordpress-gravity-forms-event-tracking#gform_pagination_event_action">our filters on GitHub</a>.
|
106 |
|
107 |
+
|
108 |
+
= Can I track when a user has filled out a form field, but not submitted? =
|
109 |
+
|
110 |
+
Yes, with the <a href="https://www.gravityforms.com/add-ons/partial-entries/">Partial Entries Add-on</a>. Edit your form and go to the 'Advanced' section and fill out your event parameters. If a partial entry is saved, the event will be sent to Google Analytics using the Measurement Protocol.
|
111 |
+
|
112 |
+
Check out the video below for an explanation:
|
113 |
+
|
114 |
+
https://www.youtube.com/watch?v=x0UpV4RjVAY&rel=0
|
115 |
+
|
116 |
= Are there any filters/hooks? =
|
117 |
|
118 |
Check out the documentation on [github](https://github.com/ronalfy/wordpress-gravity-forms-event-tracking)
|
122 |
1. The Gravity Forms setting screen where you setup your event tracking.
|
123 |
2. The form settings feed list.
|
124 |
3. The feed settings page
|
125 |
+
4. Partial entries add-on section
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
= 2.3.0 =
|
130 |
+
* Released 2018-10-03
|
131 |
+
* Added support for the Partial Entries add-on.
|
132 |
+
|
133 |
= 2.2.4 =
|
134 |
* Released 2018-10-02
|
135 |
* Adding support for custom trackers
|
269 |
|
270 |
== Upgrade Notice ==
|
271 |
|
272 |
+
= 2.3.0 =
|
273 |
+
Added support for the Partial Entries add-on.
|
274 |
+
|
275 |
= 2.2.4 =
|
276 |
Adding support for custom trackers
|
277 |
|
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.
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
@@ -120,12 +120,17 @@ class GFGAET {
|
|
120 |
// Initialize settings screen and feeds
|
121 |
GFAddOn::register( 'GFGAET_UA' );
|
122 |
GFAddOn::register( 'GFGAET_Submission_Feeds' );
|
|
|
|
|
|
|
123 |
|
124 |
// Initialize pagination
|
125 |
add_action( 'gform_post_paging', array( $this, 'pagination'), 10, 3 );
|
126 |
|
127 |
// Initialize whether Ajax is on or off
|
128 |
add_filter( 'gform_form_args', array( $this, 'maybe_ajax_only' ), 15, 1 );
|
|
|
|
|
129 |
}
|
130 |
|
131 |
/**
|
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.0
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
120 |
// Initialize settings screen and feeds
|
121 |
GFAddOn::register( 'GFGAET_UA' );
|
122 |
GFAddOn::register( 'GFGAET_Submission_Feeds' );
|
123 |
+
if( class_exists( 'GF_Partial_Entries' ) ) {
|
124 |
+
GFAddOn::register( 'GFGAET_Partial_Entries' );
|
125 |
+
}
|
126 |
|
127 |
// Initialize pagination
|
128 |
add_action( 'gform_post_paging', array( $this, 'pagination'), 10, 3 );
|
129 |
|
130 |
// Initialize whether Ajax is on or off
|
131 |
add_filter( 'gform_form_args', array( $this, 'maybe_ajax_only' ), 15, 1 );
|
132 |
+
|
133 |
+
|
134 |
}
|
135 |
|
136 |
/**
|
includes/GFGAET_Measurement_Protocol.php
CHANGED
@@ -74,7 +74,6 @@ class GFGAET_Measurement_Protocol {
|
|
74 |
if ( empty( $this->{$mp_vars[$index]} ) ) continue; // Empty params cause the payload to fail in testing
|
75 |
$mp_body[$mp_var] = $this->{$mp_vars[$index]};
|
76 |
}
|
77 |
-
|
78 |
// Add Payload
|
79 |
$payload = add_query_arg( $mp_body, $this->endpoint );
|
80 |
|
74 |
if ( empty( $this->{$mp_vars[$index]} ) ) continue; // Empty params cause the payload to fail in testing
|
75 |
$mp_body[$mp_var] = $this->{$mp_vars[$index]};
|
76 |
}
|
|
|
77 |
// Add Payload
|
78 |
$payload = add_query_arg( $mp_body, $this->endpoint );
|
79 |
|
includes/GFGAET_Partial_Entries.php
ADDED
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Credit: https://stevegrunwell.com/blog/custom-field-ids-gravity-forms/
|
3 |
+
GFForms::include_addon_framework();
|
4 |
+
class GFGAET_Partial_Entries extends GFAddOn {
|
5 |
+
protected $_version = '2.0';
|
6 |
+
protected $_min_gravityforms_version = '1.8.20';
|
7 |
+
protected $_slug = 'GFGAET_Partial_Entries';
|
8 |
+
protected $_path = 'gravity-forms-google-analytics-event-tracking/gravity-forms-event-tracking.php';
|
9 |
+
protected $_full_path = __FILE__;
|
10 |
+
protected $_title = 'Gravity Forms Google Analytics Partial Entries';
|
11 |
+
protected $_short_title = 'Event Tracking';
|
12 |
+
// Members plugin integration
|
13 |
+
protected $_capabilities = array( 'gravityforms_event_tracking', 'gravityforms_event_tracking_uninstall' );
|
14 |
+
// Permissions
|
15 |
+
protected $_capabilities_settings_page = 'gravityforms_event_tracking';
|
16 |
+
protected $_capabilities_form_settings = 'gravityforms_event_tracking';
|
17 |
+
protected $_capabilities_uninstall = 'gravityforms_event_tracking_uninstall';
|
18 |
+
|
19 |
+
|
20 |
+
private static $_instance = null;
|
21 |
+
/**
|
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() {
|
29 |
+
if ( self::$_instance == null ) {
|
30 |
+
self::$_instance = new self();
|
31 |
+
}
|
32 |
+
|
33 |
+
return self::$_instance;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Initailizes partial entries updated and saved state
|
38 |
+
*
|
39 |
+
* @since 2.3.0
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function init() {
|
44 |
+
parent::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 ) {
|
60 |
+
$form_fields = $this->get_mapped_fields( $partial_entry, $form );
|
61 |
+
foreach( $form_fields as $gform_index => $gform_values ) {
|
62 |
+
if( isset( $gform_values['event_category']) && !empty( $gform_values['event_category'] ) ) {
|
63 |
+
|
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'] ) );
|
71 |
+
$event_label = ( empty( $gform_values['event_label'] ) ? trim( $label ) : trim( $gform_values['event_label'] ) );
|
72 |
+
|
73 |
+
// Get event value
|
74 |
+
$event_value = ( empty( $gform_values['event_value'] ) ? trim( $value ) : trim( $gform_values['event_value'] ) );
|
75 |
+
if( !is_numeric( $event_value ) ) {
|
76 |
+
$event_value = 0;
|
77 |
+
}
|
78 |
+
$event_value = absint( round( GFCommon::to_number( $event_value ) ) );
|
79 |
+
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Filter: gform_partial_event_category
|
83 |
+
*
|
84 |
+
* Filter the event category dynamically
|
85 |
+
*
|
86 |
+
* @since 2.3.0
|
87 |
+
*
|
88 |
+
* @param string $event_category Event Category
|
89 |
+
* @param array $form Gravity Form form array
|
90 |
+
* @param array $partial_entry Gravity Form Partial Entry array
|
91 |
+
* @param string $value Gravity Forms Field value
|
92 |
+
* @param string label Label of the form entry
|
93 |
+
*/
|
94 |
+
$event_category = apply_filters( 'gform_partial_event_category', $event_category, $form, $partial_entry, $value, $label );
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Filter: gform_partial_event_action
|
98 |
+
*
|
99 |
+
* Filter the event action dynamically
|
100 |
+
*
|
101 |
+
* @since 2.3.0
|
102 |
+
*
|
103 |
+
* @param string $event_action Event action
|
104 |
+
* @param array $form Gravity Form form array
|
105 |
+
* @param array $partial_entry Gravity Form Partial Entry array
|
106 |
+
* @param string $value Gravity Forms Field value
|
107 |
+
* @param string label Label of the form entry
|
108 |
+
*/
|
109 |
+
$event_action = apply_filters( 'gform_partial_event_action', $event_action, $form, $partial_entry, $value, $label );
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Filter: gform_partial_event_label
|
113 |
+
*
|
114 |
+
* Filter the event label dynamically
|
115 |
+
*
|
116 |
+
* @since 2.3.0
|
117 |
+
*
|
118 |
+
* @param string $event_label Event label
|
119 |
+
* @param array $form Gravity Form form array
|
120 |
+
* @param array $partial_entry Gravity Form Partial Entry array
|
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_action', $event_label, $form, $partial_entry, $value, $label );
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Filter: gform_partial_event_value
|
128 |
+
*
|
129 |
+
* Filter the event value dynamically
|
130 |
+
*
|
131 |
+
* @since 2.3.0
|
132 |
+
*
|
133 |
+
* @param string $event_value Event value
|
134 |
+
* @param array $form Gravity Form form array
|
135 |
+
* @param array $partial_entry Gravity Form Partial Entry array
|
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_action', $event_value, $form, $partial_entry, $value, $label );
|
140 |
+
|
141 |
+
// Let's set up the measurement protocol
|
142 |
+
$ua_code = GFGAET::get_ua_code();
|
143 |
+
$event = new GFGAET_Measurement_Protocol();
|
144 |
+
$event->init();
|
145 |
+
$event->set_event_category( $event_category );
|
146 |
+
$event->set_event_action( $event_action );
|
147 |
+
$event->set_event_label( $event_label );
|
148 |
+
$event->set_event_value( $event_value );
|
149 |
+
$event->send( $ua_code );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
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 );
|
175 |
+
$event_category = isset( $field['field_partial_entries_category'] ) ? $field['field_partial_entries_category'] : '' ;
|
176 |
+
$event_action = isset( $field['field_partial_entries_action'] ) ? $field['field_partial_entries_action'] : '';
|
177 |
+
$event_label = isset( $field['field_partial_entries_label'] ) ? $field['field_partial_entries_label'] : '';
|
178 |
+
$event_value = isset( $field['field_partial_entries_value'] ) ? $field['field_partial_entries_value'] : '0';
|
179 |
+
$event_category = GFCommon::replace_variables( $event_category, $form, $entry );
|
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'].
|
201 |
+
*/
|
202 |
+
$mapping[ $field_id ] = array(
|
203 |
+
'value' => $entry[ $input['id'] ],
|
204 |
+
'label' => $field['label'],
|
205 |
+
'event_category' => $event_category,
|
206 |
+
'event_action' => $event_action,
|
207 |
+
'event_label' => $event_label,
|
208 |
+
'event_value' => $event_value
|
209 |
+
);
|
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,
|
218 |
+
'event_value' => $event_value
|
219 |
+
);
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
return $mapping;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
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() {
|
234 |
+
parent::init_admin();
|
235 |
+
add_action( 'gform_field_advanced_settings', array( $this, 'advanced_settings' ), 10, 2 );
|
236 |
+
add_action( 'gform_editor_js', array( $this, 'editor_script' ) );
|
237 |
+
add_filter( 'gform_tooltips', array( $this, 'add_tooltips' ) );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
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 ) {
|
250 |
+
$tooltips['gfgaet_category'] = __( 'Event category which you would like to send to Google Analytics using Partial Entries. Merge tags are not allowed.', 'gravity-forms-google-analytics-event-tracking' );
|
251 |
+
$tooltips['gfgaet_action'] = __( 'Event action which you would like to send to Google Analytics using Partial Entries. Merge tags are not allowed.', 'gravity-forms-google-analytics-event-tracking' );
|
252 |
+
$tooltips['gfgaet_label'] = __( 'Event label which you would like to send to Google Analytics using Partial Entries. Merge tags are not allowed. If left blank, the form value will be used.', 'gravity-forms-google-analytics-event-tracking' );
|
253 |
+
$tooltips['gfgaet_value'] = __( 'Event value (Integers only) which you would like to send to Google Analytics using Partial Entries. Merge tags are not allowed. If left blank, the form value will be used assuming it is an integer.', 'gravity-forms-google-analytics-event-tracking' );
|
254 |
+
return $tooltips;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
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 |
+
);
|
271 |
+
}
|
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() {
|
281 |
+
/*
|
282 |
+
* Add .field_id_setting onto the end of each field
|
283 |
+
* type's properties.
|
284 |
+
*/
|
285 |
+
?>
|
286 |
+
<script type="text/javascript">
|
287 |
+
jQuery.map(fieldSettings, function (el, i) {
|
288 |
+
fieldSettings[i] += ', .admin_partial_entry_category, .admin_partial_entry_action, .admin_partial_entry_label, .admin_partial_entry_value';
|
289 |
+
});
|
290 |
+
// Populate field settings on initialization.
|
291 |
+
jQuery(document).on('gform_load_field_settings', function(ev, field){
|
292 |
+
jQuery(document.getElementById('field_partial_entries_category')).val(field.field_partial_entries_category || '');
|
293 |
+
jQuery(document.getElementById('field_partial_entries_action')).val(field.field_partial_entries_action || '');
|
294 |
+
jQuery(document.getElementById('field_partial_entries_label')).val(field.field_partial_entries_label || '');
|
295 |
+
jQuery(document.getElementById('field_partial_entries_value')).val(field.field_partial_entries_value || '');
|
296 |
+
});
|
297 |
+
</script>
|
298 |
+
<?php
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
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 ) {
|
312 |
+
if( 100 !== $position ) return;
|
313 |
+
?>
|
314 |
+
<li class="admin_partial_entry_category field_setting">
|
315 |
+
<label for="field_partial_entries_category" class="section_label">
|
316 |
+
<?php _e( 'Event Category', 'gravity-forms-google-analytics-event-tracking' ); ?>
|
317 |
+
<?php gform_tooltip( 'gfgaet_category' ); ?>
|
318 |
+
</label>
|
319 |
+
<input type="text" id="field_partial_entries_category" class="partial-entries-category fieldwidth-2" onChange="SetFieldProperty( 'field_partial_entries_category', this.value );" oninput="SetFieldProperty( 'field_partial_entries_category', this.value );" />
|
320 |
+
</li>
|
321 |
+
<li class="admin_partial_entry_action field_setting">
|
322 |
+
<label for="field_partial_entries_action" class="section_label">
|
323 |
+
<?php _e( 'Event Action', 'gravity-forms-google-analytics-event-tracking' ); ?>
|
324 |
+
<?php gform_tooltip( 'gfgaet_action' ); ?>
|
325 |
+
</label>
|
326 |
+
<input type="text" id="field_partial_entries_action" class="partial-entries-action fieldwidth-2" onChange="SetFieldProperty( 'field_partial_entries_action', this.value );" oninput="SetFieldProperty( 'field_partial_entries_action', this.value );" />
|
327 |
+
</li>
|
328 |
+
<li class="admin_partial_entry_label field_setting">
|
329 |
+
<label for="field_partial_entries_label" class="section_label">
|
330 |
+
<?php _e( 'Event Label', 'gravity-forms-google-analytics-event-tracking' ); ?>
|
331 |
+
<?php gform_tooltip( 'gfgaet_label' ); ?>
|
332 |
+
</label>
|
333 |
+
<input type="text" id="field_partial_entries_label" class="partial-entries-label fieldwidth-2" onChange="SetFieldProperty( 'field_partial_entries_label', this.value );" oninput="SetFieldProperty( 'field_partial_entries_label', this.value );" />
|
334 |
+
</li>
|
335 |
+
<li class="admin_partial_entry_value field_setting">
|
336 |
+
<label for="field_partial_entries_value" class="section_label">
|
337 |
+
<?php _e( 'Event Value', 'gravity-forms-google-analytics-event-tracking' ); ?>
|
338 |
+
<?php gform_tooltip( 'gfgaet_value' ); ?>
|
339 |
+
</label>
|
340 |
+
<input type="text" id="field_partial_entries_value" class="partial-entries-value fieldwidth-2" onChange="SetFieldProperty( 'field_partial_entries_value', this.value );" oninput="SetFieldProperty( 'field_partial_entries_value', this.value );" />
|
341 |
+
</li>
|
342 |
+
<?php
|
343 |
+
}
|
344 |
+
}
|