Version Description
- Released 2016-09-22
- Enhancement: Can track pagination events
- Enhancement: Can track events using JavaScript only (a highly requested feature)
- Enhancement: Can use Google Tag Manager
Download this release
Release Info
Developer | ronalfy |
Plugin | Event Tracking for Gravity Forms |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.7.3 to 2.0.0
- LICENSE.txt +0 -0
- README.txt +38 -23
- assets/banner-772x250.png +0 -0
- assets/icon-128x128.png +0 -0
- assets/icon-256x256.png +0 -0
- assets/icon-32x32.png +0 -0
- assets/icon-64x64.png +0 -0
- assets/screenshot-1.png +0 -0
- assets/screenshot-2.png +0 -0
- assets/screenshot-3.png +0 -0
- gravity-forms-event-tracking.php +202 -31
- includes/GFGAET_Pagination.php +150 -0
- includes/{class-gravity-forms-event-tracking-feed.php → GFGAET_Submission_Feeds.php} +142 -243
- includes/GFGAET_Tag_Manager.php +60 -0
- includes/GFGAET_UA.php +116 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Autoloader.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Client/AbstractClientAdapter.php +0 -63
- includes/vendor/ga-mp/src/Racecore/GATracking/Client/Adapter/Socket.php +0 -123
- includes/vendor/ga-mp/src/Racecore/GATracking/Client/ClientAdapterInterface.php +0 -12
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception/EndpointServerException.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception/InvalidArgumentException.php +0 -25
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception/InvalidOptionException.php +0 -25
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception/MissingConfigurationException.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Exception/MissingTrackingParameterException.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/GATracking.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Request/TrackingRequest.php +0 -48
- includes/vendor/ga-mp/src/Racecore/GATracking/Request/TrackingRequestCollection.php +0 -87
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/AbstractTracking.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/App/Event.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/App/Screen.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Campaign.php +0 -233
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Item.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Event.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Exception.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Factory.php +0 -43
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Page.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Social.php +0 -0
- includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/User/Timing.php +0 -0
- index.php +0 -0
- languages/gravity-forms-google-analytics-event-tracking.pot +0 -0
- languages/index.php +0 -0
- uninstall.php +0 -76
LICENSE.txt
CHANGED
File without changes
|
README.txt
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
=== Gravity Forms Google Analytics Event Tracking ===
|
2 |
-
Contributors: nmarks, ronalfy
|
3 |
-
Tags: gravity forms, google analytics, event tracking
|
4 |
Requires at least:4.0
|
5 |
Tested up to: 4.6
|
6 |
-
Stable tag:
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
-
Donate link: https://mediaron.com/contribute/
|
10 |
|
11 |
Add Google Analytics Event Tracking to your Gravity Forms in less than 5 minutes! Requires PHP 5.3+.
|
12 |
|
@@ -14,36 +13,35 @@ Add Google Analytics Event Tracking to your Gravity Forms in less than 5 minutes
|
|
14 |
|
15 |
This plugin provides an easy way to add Google Analytics event tracking to your Gravity Forms, allowing you to properly track form submissions as events/conversions within Google Analytics.
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
= Setup Guide =
|
18 |
-
Looking for help setting things up? [Read
|
19 |
|
20 |
= Minimum Requirements =
|
21 |
- PHP 5.3+
|
22 |
- Gravity Forms 1.8.20+
|
23 |
-
- Google Analytics Universal Analytics
|
|
|
24 |
|
25 |
= Features =
|
26 |
-
-
|
27 |
- Add multiple event feeds with conditionals
|
28 |
- Custom event categories, actions, labels and even values
|
|
|
29 |
- Dynamic event value on payment forms (integration with the payment add-ons including Paypal Standard, PayPal Pro, Stripe, etc...)
|
30 |
-
- Awesomeness
|
31 |
-
|
32 |
-
= Configuration =
|
33 |
-
If you meet all the requirements of this plugin, you can simply install this plugin in your WordPress plugins folder.
|
34 |
-
|
35 |
-
Once this plugin is activated, you can browse to the Gravity Forms settings and find a new sub-menu item called <strong>Event Tracker</strong>. There, you will enter your <a href="https://support.google.com/analytics/answer/1032385?hl=en">Google Analytics Tracking Code</a>.
|
36 |
-
|
37 |
-
The plugin provides some <a href="http://www.nvisionsolutions.ca/blog/search-engine-optimization/gravity-forms-scalable-event-tracking-google-analytics/">default event categories, labels, and actions</a>. You can override these per form by going into the individual form's settings.
|
38 |
-
|
39 |
-
Within Google Analytics, you will want to set up an <a href="https://support.google.com/analytics/answer/1032415?hl=en">event-based goal</a> and match the event label, event category, and event action with the ones you set up.
|
40 |
-
|
41 |
-
On each form, you need to make sure to setup an Event Tracking Feed. Open each forms settings, go to the "Event Tracking" section, and set one up. Leave the fields blank to use the default values.
|
42 |
|
43 |
For payment based forms, you can leave the value blank to convert using the total payment amount.
|
44 |
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
|
48 |
== Installation ==
|
49 |
|
@@ -76,9 +74,17 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
76 |
|
77 |
== Frequently Asked Questions ==
|
78 |
|
79 |
-
= How do I
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
|
|
|
|
82 |
|
83 |
= Are there any filters/hooks? =
|
84 |
|
@@ -92,6 +98,12 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
92 |
|
93 |
== Changelog ==
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
= 1.7.3 =
|
96 |
* Bugfix - Some users were experiencing PHP fatal errors upon form submission. Reverting to previously used library.
|
97 |
|
@@ -175,6 +187,9 @@ Check out the documentation on [github](https://github.com/ronalfy/wordpress-gra
|
|
175 |
|
176 |
== Upgrade Notice ==
|
177 |
|
|
|
|
|
|
|
178 |
= 1.7.3 =
|
179 |
Bugfix - Some users were experiencing PHP fatal errors upon form submission. Reverting to previously used library.
|
180 |
|
1 |
=== Gravity Forms Google Analytics Event Tracking ===
|
2 |
+
Contributors: nmarks, ronalfy, bigwing
|
3 |
+
Tags: gravity forms, google analytics, google tag manager, event tracking
|
4 |
Requires at least:4.0
|
5 |
Tested up to: 4.6
|
6 |
+
Stable tag: 2.0.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
9 |
|
10 |
Add Google Analytics Event Tracking to your Gravity Forms in less than 5 minutes! Requires PHP 5.3+.
|
11 |
|
13 |
|
14 |
This plugin provides an easy way to add Google Analytics event tracking to your Gravity Forms, allowing you to properly track form submissions as events/conversions within Google Analytics.
|
15 |
|
16 |
+
Also supports:
|
17 |
+
|
18 |
+
* Pagination events
|
19 |
+
* JS only events
|
20 |
+
* Google Tag Manager
|
21 |
+
|
22 |
= Setup Guide =
|
23 |
+
Looking for help setting things up? [Read Our Setup Guide](https://bigwing.com/nest/gravity-forms-event-tracking-google-analytics)
|
24 |
|
25 |
= Minimum Requirements =
|
26 |
- PHP 5.3+
|
27 |
- Gravity Forms 1.8.20+
|
28 |
+
- Google Analytics Universal Analytics
|
29 |
+
- Google Tag Manager (optional)
|
30 |
|
31 |
= Features =
|
32 |
+
- Submit events to Google Analytics using the Measurement Protocol, JavaScript, or using Google Tag Manager
|
33 |
- Add multiple event feeds with conditionals
|
34 |
- Custom event categories, actions, labels and even values
|
35 |
+
- Track form pagination events
|
36 |
- Dynamic event value on payment forms (integration with the payment add-ons including Paypal Standard, PayPal Pro, Stripe, etc...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
For payment based forms, you can leave the value blank to convert using the total payment amount.
|
39 |
|
40 |
+
<h3>Help Contribute</h3>
|
41 |
+
|
42 |
+
* Leave a star rating
|
43 |
+
* <a href="https://translate.wordpress.org/projects/wp-plugins/gravity-forms-google-analytics-event-tracking">Contribute a translation</a>
|
44 |
+
* <a href="https://github.com/ronalfy/wordpress-gravity-forms-event-tracking">Contribute some code</a>
|
45 |
|
46 |
== Installation ==
|
47 |
|
74 |
|
75 |
== Frequently Asked Questions ==
|
76 |
|
77 |
+
= How do I track pagination? =
|
78 |
+
|
79 |
+
<a href="https://bigwing.com/nest/gravity-forms-event-tracking-google-analytics/pagination/">Read our Guide on Pagination</a>.
|
80 |
+
|
81 |
+
= How do I track using JavaScript only? =
|
82 |
+
|
83 |
+
See <a href="https://bigwing.com/nest/gravity-forms-event-tracking-google-analytics/advanced/">Going Advanced</a>.
|
84 |
|
85 |
+
= Does this work with Google Tag Manager =
|
86 |
+
|
87 |
+
Yes. <a href="https://bigwing.com/nest/gravity-forms-event-tracking-google-analytics/google-tag-manager/">Read our Guide on Google Tag Manager</a>.
|
88 |
|
89 |
= Are there any filters/hooks? =
|
90 |
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 2.0.0 =
|
102 |
+
* Released 2016-09-22
|
103 |
+
* Enhancement: Can track pagination events
|
104 |
+
* Enhancement: Can track events using JavaScript only (a highly requested feature)
|
105 |
+
* Enhancement: Can use Google Tag Manager
|
106 |
+
|
107 |
= 1.7.3 =
|
108 |
* Bugfix - Some users were experiencing PHP fatal errors upon form submission. Reverting to previously used library.
|
109 |
|
187 |
|
188 |
== Upgrade Notice ==
|
189 |
|
190 |
+
= 2.0.0 =
|
191 |
+
Numerous enhancements, including pagination tracking. See the Changelog for more information.
|
192 |
+
|
193 |
= 1.7.3 =
|
194 |
Bugfix - Some users were experiencing PHP fatal errors upon form submission. Reverting to previously used library.
|
195 |
|
assets/banner-772x250.png
DELETED
Binary file
|
assets/icon-128x128.png
DELETED
Binary file
|
assets/icon-256x256.png
DELETED
Binary file
|
assets/icon-32x32.png
DELETED
Binary file
|
assets/icon-64x64.png
DELETED
Binary file
|
assets/screenshot-1.png
DELETED
Binary file
|
assets/screenshot-2.png
DELETED
Binary file
|
assets/screenshot-3.png
DELETED
Binary file
|
gravity-forms-event-tracking.php
CHANGED
@@ -1,23 +1,16 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
5 |
-
* @license GPL-2.0+
|
6 |
-
* @link http://www.nvisionsolutions.ca
|
7 |
-
* @copyright 2014-2015 Nathan Marks
|
8 |
-
*
|
9 |
-
* @wordpress-plugin
|
10 |
-
* Plugin Name: Gravity Forms Google Analytics Event Tracking
|
11 |
* Plugin URI: https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking/
|
12 |
* Description: Add Google Analytics event tracking to your Gravity Forms with ease.
|
13 |
-
* Version:
|
14 |
* Author: Ronald Huereca
|
15 |
* Author URI: https://mediaron.com
|
16 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
17 |
* License: GPL-2.0+
|
18 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
19 |
* Domain Path: /languages
|
20 |
-
*
|
21 |
*/
|
22 |
|
23 |
// If this file is called directly, abort.
|
@@ -25,40 +18,218 @@ if ( ! defined( 'WPINC' ) ) {
|
|
25 |
die;
|
26 |
}
|
27 |
|
28 |
-
class
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
|
|
|
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
|
|
|
|
|
|
47 |
|
48 |
-
//
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return false;
|
53 |
}
|
54 |
-
return true;
|
55 |
-
}
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
-
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: Gravity Forms Event Tracking
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
* Plugin URI: https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking/
|
5 |
* Description: Add Google Analytics event tracking to your Gravity Forms with ease.
|
6 |
+
* Version: 2.0.0
|
7 |
* Author: Ronald Huereca
|
8 |
* Author URI: https://mediaron.com
|
9 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
10 |
* License: GPL-2.0+
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
12 |
* Domain Path: /languages
|
13 |
+
* Developer Credit: Nathan Marks
|
14 |
*/
|
15 |
|
16 |
// If this file is called directly, abort.
|
18 |
die;
|
19 |
}
|
20 |
|
21 |
+
class GFGAET {
|
22 |
|
23 |
+
/**
|
24 |
+
* Holds the class instance.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
* @access private
|
28 |
+
*/
|
29 |
+
private static $instance = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Retrieve a class instance.
|
33 |
+
*
|
34 |
+
* @since 2.0.0
|
35 |
+
*/
|
36 |
+
public static function get_instance() {
|
37 |
+
if ( null == self::$instance ) {
|
38 |
+
self::$instance = new self;
|
39 |
}
|
40 |
+
return self::$instance;
|
41 |
+
} //end get_instance
|
42 |
|
43 |
+
/**
|
44 |
+
* Class constructor.
|
45 |
+
*
|
46 |
+
* @since 2.0.0
|
47 |
+
*/
|
48 |
+
private function __construct() {
|
49 |
+
load_plugin_textdomain( 'gravity-forms-google-analytics-event-tracking', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
50 |
+
|
51 |
+
spl_autoload_register( array( $this, 'loader' ) );
|
52 |
+
|
53 |
+
add_action( 'gform_loaded', array( $this, 'gforms_loaded' ) );
|
54 |
+
}
|
55 |
|
56 |
+
/**
|
57 |
+
* Check for the minimum supported PHP version.
|
58 |
+
*
|
59 |
+
* @since 2.0.0
|
60 |
+
*
|
61 |
+
* @return bool true if meets minimum version, false if not
|
62 |
+
*/
|
63 |
+
public static function check_php_version() {
|
64 |
+
if( ! version_compare( '5.3', PHP_VERSION, '<=' ) ) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
return true;
|
68 |
+
}
|
69 |
|
70 |
+
/**
|
71 |
+
* Check the plugin to make sure it meets the minimum requirements.
|
72 |
+
*
|
73 |
+
* @since 2.0.0
|
74 |
+
*/
|
75 |
+
public static function check_plugin() {
|
76 |
+
if( ! GFGAET::check_php_version() ) {
|
77 |
+
deactivate_plugins( GFGAET::get_plugin_basename() );
|
78 |
+
exit( sprintf( esc_html__( 'Gravity Forms Event Tracking requires PHP version 5.3 and up. You are currently running PHP version %s.', 'gravity-forms-google-analytics-event-tracking' ), esc_html( PHP_VERSION ) ) );
|
79 |
+
}
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Retrieve the plugin basename.
|
84 |
+
*
|
85 |
+
* @since 2.0.0
|
86 |
+
*
|
87 |
+
* @return string plugin basename
|
88 |
+
*/
|
89 |
+
public static function get_plugin_basename() {
|
90 |
+
return plugin_basename( __FILE__ );
|
91 |
+
}
|
92 |
|
93 |
+
/**
|
94 |
+
* Return the absolute path to an asset.
|
95 |
+
*
|
96 |
+
* @since 2.0.0
|
97 |
+
*
|
98 |
+
* @param string @path Relative path to the asset.
|
99 |
+
*
|
100 |
+
* return string Absolute path to the relative asset.
|
101 |
+
*/
|
102 |
+
public static function get_plugin_dir( $path = '' ) {
|
103 |
+
$dir = rtrim( plugin_dir_path(__FILE__), '/' );
|
104 |
+
if ( !empty( $path ) && is_string( $path) )
|
105 |
+
$dir .= '/' . ltrim( $path, '/' );
|
106 |
+
return $dir;
|
107 |
+
}
|
108 |
|
109 |
+
/**
|
110 |
+
* Initialize Gravity Forms related add-ons.
|
111 |
+
*
|
112 |
+
* @since 2.0.0
|
113 |
+
*/
|
114 |
+
public function gforms_loaded() {
|
115 |
+
if ( ! GFGAET::check_php_version() ) return;
|
116 |
+
if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) {
|
117 |
+
return;
|
118 |
+
}
|
119 |
|
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 |
+
/**
|
132 |
+
* Get the Google Analytics UA Code
|
133 |
+
*
|
134 |
+
* @since 2.0.0
|
135 |
+
* @return string/bool Returns string UA code, false otherwise
|
136 |
+
*/
|
137 |
+
public static function get_ua_code() {
|
138 |
+
$gravity_forms_add_on_settings = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
|
139 |
+
|
140 |
+
$ua_id = isset( $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua' ] ) ? $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua' ] : false;
|
141 |
+
|
142 |
+
$ua_regex = "/^UA-[0-9]{5,}-[0-9]{1,}$/";
|
143 |
+
|
144 |
+
if ( preg_match( $ua_regex, $ua_id ) ) {
|
145 |
+
return $ua_id;
|
146 |
+
}
|
147 |
return false;
|
148 |
}
|
|
|
|
|
149 |
|
150 |
+
/**
|
151 |
+
* Checks whether Google Analytics mode is activated for sending events.
|
152 |
+
*
|
153 |
+
* @since 2.0.0
|
154 |
+
*
|
155 |
+
* @return bool true if GA only, false if not
|
156 |
+
*/
|
157 |
+
public static function is_ga_only() {
|
158 |
+
$ga_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', false );
|
159 |
+
if ( ! isset( $ga_options[ 'mode' ] ) ) {
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
if ( 'ga' == $ga_options[ 'mode' ] ) {
|
163 |
+
return true;
|
164 |
+
}
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Checks whether Tag Manager only mode is activated for sending events.
|
170 |
+
*
|
171 |
+
* @since 2.0.0
|
172 |
+
*
|
173 |
+
* @return bool true if GTM only, false if not
|
174 |
+
*/
|
175 |
+
public static function is_gtm_only() {
|
176 |
+
$ga_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', false );
|
177 |
+
if ( ! isset( $ga_options[ 'mode' ] ) ) {
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
if ( 'gtm' == $ga_options[ 'mode' ] ) {
|
181 |
+
return true;
|
182 |
+
}
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Autoload class files.
|
188 |
+
*
|
189 |
+
* @since 2.0.0
|
190 |
+
*
|
191 |
+
* @param string $class_name The class name
|
192 |
+
*/
|
193 |
+
public function loader( $class_name ) {
|
194 |
+
if ( class_exists( $class_name, false ) || false === strpos( $class_name, 'GFGAET' ) ) {
|
195 |
+
return;
|
196 |
+
}
|
197 |
+
$file = GFGAET::get_plugin_dir( "includes/{$class_name}.php" );
|
198 |
+
if ( file_exists( $file ) ) {
|
199 |
+
include_once( $file );
|
200 |
+
}
|
201 |
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Sets all forms to Ajax only depeneding on settings
|
205 |
+
*
|
206 |
+
* @since 2.0.0
|
207 |
+
*
|
208 |
+
* @param array $form_args The form arguments
|
209 |
+
*/
|
210 |
+
public function maybe_ajax_only( $form_args ) {
|
211 |
+
$gravity_forms_add_on_settings = get_option( 'gravityformsaddon_GFGAET_UA_settings', array() );
|
212 |
+
|
213 |
+
if ( isset( $gravity_forms_add_on_settings[ 'ajax_only' ] ) && 'on' == $gravity_forms_add_on_settings[ 'ajax_only' ] ) {
|
214 |
+
$form_args[ 'ajax' ] = true;
|
215 |
+
}
|
216 |
+
return $form_args;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Initialize the pagination events.
|
221 |
+
*
|
222 |
+
* @since 2.0.0
|
223 |
+
*
|
224 |
+
* @param array $form The form arguments
|
225 |
+
* @param int @source_page_number The original page number
|
226 |
+
* @param int $current_page_number The new page number
|
227 |
+
*/
|
228 |
+
public function pagination( $form, $source_page_number, $current_page_number ) {
|
229 |
+
$pagination = GFGAET_Pagination::get_instance();
|
230 |
+
$pagination->paginate( $form, $source_page_number, $current_page_number );
|
231 |
+
}
|
232 |
}
|
233 |
+
|
234 |
+
register_activation_hook( __FILE__, array( 'GFGAET', 'check_plugin' ) );
|
235 |
+
GFGAET::get_instance();
|
includes/GFGAET_Pagination.php
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GFGAET_Pagination {
|
3 |
+
/**
|
4 |
+
* Holds the class instance.
|
5 |
+
*
|
6 |
+
* @since 2.0.0
|
7 |
+
* @access private
|
8 |
+
*/
|
9 |
+
private static $instance = null;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Retrieve a class instance.
|
13 |
+
*
|
14 |
+
* @since 2.0.0
|
15 |
+
*/
|
16 |
+
public static function get_instance() {
|
17 |
+
if ( null == self::$instance ) {
|
18 |
+
self::$instance = new self;
|
19 |
+
}
|
20 |
+
return self::$instance;
|
21 |
+
} //end get_instance
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Class constructor.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
*/
|
28 |
+
private function __construct() {
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Send pagination events.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
*
|
37 |
+
* @param array $form The form arguments
|
38 |
+
* @param int @source_page_number The original page number
|
39 |
+
* @param int $current_page_number The new page number
|
40 |
+
*/
|
41 |
+
public function paginate( $form, $source_page_number, $current_page_number ) {
|
42 |
+
require_once( 'vendor/ga-mp/src/Racecore/GATracking/Autoloader.php');
|
43 |
+
Racecore\GATracking\Autoloader::register( dirname(__FILE__) . '/vendor/ga-mp/src/' );
|
44 |
+
|
45 |
+
$ua_code = GFGAET::get_ua_code();
|
46 |
+
if ( false !== $ua_code ) {
|
47 |
+
$event = new \Racecore\GATracking\Tracking\Event();
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Filter: gform_pagination_event_category
|
51 |
+
*
|
52 |
+
* Filter the event category dynamically
|
53 |
+
*
|
54 |
+
* @since 2.0.0
|
55 |
+
*
|
56 |
+
* @param string $category Event Category
|
57 |
+
* @param array $form Gravity Form form array
|
58 |
+
* @param int $source_page_number Source page number
|
59 |
+
* @param int $current_page_number Current Page Number
|
60 |
+
*/
|
61 |
+
$event_category = apply_filters( 'gform_pagination_event_category', 'form', $form, $source_page_number, $current_page_number );
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Filter: gform_pagination_event_action
|
65 |
+
*
|
66 |
+
* Filter the event action dynamically
|
67 |
+
*
|
68 |
+
* @since 2.0.0
|
69 |
+
*
|
70 |
+
* @param string $action Event Action
|
71 |
+
* @param array $form Gravity Form form array
|
72 |
+
* @param int $source_page_number Source page number
|
73 |
+
* @param int $current_page_number Current Page Number
|
74 |
+
*/
|
75 |
+
$event_action = apply_filters( 'gform_pagination_event_action', 'pagination', $form, $source_page_number, $current_page_number );
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Filter: gform_pagination_event_label
|
79 |
+
*
|
80 |
+
* Filter the event label dynamically
|
81 |
+
*
|
82 |
+
* @since 2.0.0
|
83 |
+
*
|
84 |
+
* @param string $label Event Label
|
85 |
+
* @param array $form Gravity Form form array
|
86 |
+
* @param int $source_page_number Source page number
|
87 |
+
* @param int $current_page_number Current Page Number
|
88 |
+
*/
|
89 |
+
$event_label = sprintf( '%s::%d::%d', esc_html( $form['title'] ), absint( $source_page_number ), absint( $current_page_number ) );
|
90 |
+
$event_label = apply_filters( 'gform_pagination_event_label', $event_label, $form, $source_page_number, $current_page_number );
|
91 |
+
|
92 |
+
// Set the event meta
|
93 |
+
$event->setEventCategory( $event_category );
|
94 |
+
$event->setEventAction( $event_action );
|
95 |
+
$event->setEventLabel( $event_label );
|
96 |
+
|
97 |
+
if ( GFGAET::is_ga_only() ) {
|
98 |
+
?>
|
99 |
+
<script>
|
100 |
+
if ( typeof window.parent.ga == 'undefined' ) {
|
101 |
+
if ( typeof window.parent.__gaTracker != 'undefined' ) {
|
102 |
+
window.parent.ga = window.parent.__gaTracker;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
if ( typeof window.parent.ga != 'undefined' ) {
|
106 |
+
|
107 |
+
// Try to get original UA code from third-party plugins or tag manager
|
108 |
+
var default_ua_code = null;
|
109 |
+
window.parent.ga(function(tracker) {
|
110 |
+
default_ua_code = tracker.get('trackingId');
|
111 |
+
});
|
112 |
+
|
113 |
+
// If UA code matches, use that tracker
|
114 |
+
if ( default_ua_code == '<?php echo esc_js( $ua_code ); ?>' ) {
|
115 |
+
window.parent.ga( 'send', 'event', '<?php echo esc_js( $event_category ); ?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>' );
|
116 |
+
} else {
|
117 |
+
// UA code doesn't match, use another tracker
|
118 |
+
window.parent.ga( 'create', '<?php echo esc_js( $ua_code ); ?>', 'auto', 'GTGAET_Tracker' );
|
119 |
+
window.parent.ga( 'GTGAET_Tracker.send', 'event', '<?php echo esc_js( $event_category );?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>' );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
</script>
|
123 |
+
<?php
|
124 |
+
return;
|
125 |
+
} else if ( GFGAET::is_gtm_only() ) {
|
126 |
+
?>
|
127 |
+
<script>
|
128 |
+
if ( typeof( window.parent.dataLayer ) != 'undefined' ) {
|
129 |
+
window.parent.dataLayer.push({'event': 'GFTrackEvent',
|
130 |
+
'GFTrackCategory':'<?php echo esc_js( $event_category ); ?>',
|
131 |
+
'GFTrackAction':'<?php echo esc_js( $event_action ); ?>s',
|
132 |
+
'GFTrackLabel':'<?php echo esc_js( $event_label ); ?>'
|
133 |
+
});
|
134 |
+
}
|
135 |
+
</script>
|
136 |
+
<?php
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
// Submit the event
|
141 |
+
$tracking = new \Racecore\GATracking\GATracking( $ua_code );
|
142 |
+
try {
|
143 |
+
$tracking->sendTracking( $event );
|
144 |
+
} catch (Exception $e) {
|
145 |
+
error_log( $e->getMessage() . ' in ' . get_class( $e ) );
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
}
|
150 |
+
}
|
includes/{class-gravity-forms-event-tracking-feed.php → GFGAET_Submission_Feeds.php}
RENAMED
@@ -9,27 +9,17 @@
|
|
9 |
* @copyright 2014 Nathan Marks
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
GFForms::include_feed_addon_framework();
|
14 |
|
15 |
-
class
|
16 |
|
17 |
-
protected $_version = "
|
18 |
protected $_min_gravityforms_version = "1.8.20";
|
19 |
-
|
20 |
-
/**
|
21 |
-
* The actual slug of this plugin is too long for GF settings to save properly.
|
22 |
-
* With the appended/prepended string it attempts to insert an option over
|
23 |
-
* 64 chars in length.
|
24 |
-
*
|
25 |
-
* @TODO Resolve this in 2.0 somehow...
|
26 |
-
*/
|
27 |
protected $_slug = "gravity-forms-event-tracking";
|
28 |
protected $_path = "gravity-forms-google-analytics-event-tracking/gravity-forms-event-tracking.php";
|
29 |
protected $_full_path = __FILE__;
|
30 |
-
protected $_url = "https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking";
|
31 |
protected $_title = "Gravity Forms Google Analytics Event Tracking";
|
32 |
-
protected $_short_title = "
|
33 |
|
34 |
// Members plugin integration
|
35 |
protected $_capabilities = array( 'gravityforms_event_tracking', 'gravityforms_event_tracking_uninstall' );
|
@@ -45,7 +35,7 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
45 |
|
46 |
public static function get_instance() {
|
47 |
if ( self::$_instance == null ) {
|
48 |
-
self::$_instance = new
|
49 |
}
|
50 |
|
51 |
return self::$_instance;
|
@@ -56,49 +46,21 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
56 |
* See comment above for explanation.
|
57 |
*/
|
58 |
public function init() {
|
59 |
-
|
60 |
-
load_plugin_textdomain( 'gravity-forms-google-analytics-event-tracking', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
61 |
-
|
62 |
-
add_filter( 'gform_logging_supported', array( $this, 'set_logging_supported' ) );
|
63 |
-
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_action_links' ) );
|
64 |
-
|
65 |
-
if ( RG_CURRENT_PAGE == 'admin-ajax.php' ) {
|
66 |
-
|
67 |
-
//If gravity forms is supported, initialize AJAX
|
68 |
-
if ( $this->is_gravityforms_supported() ) {
|
69 |
-
$this->init_ajax();
|
70 |
-
}
|
71 |
-
} else if ( is_admin() ) {
|
72 |
-
|
73 |
-
$this->init_admin();
|
74 |
-
|
75 |
-
} else {
|
76 |
-
|
77 |
-
if ( $this->is_gravityforms_supported() ) {
|
78 |
-
$this->init_frontend();
|
79 |
-
}
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
* Public facing init
|
87 |
*
|
88 |
-
* @since
|
89 |
*/
|
90 |
public function init_frontend() {
|
91 |
|
92 |
parent::init_frontend();
|
93 |
-
|
94 |
-
// Move this hook so everything else is all done and dusted first!
|
95 |
-
remove_filter( 'gform_entry_post_save', array( $this, 'maybe_process_feed' ) );
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
add_filter( 'gform_after_submission', array( $this, 'maybe_process_feed' ), 10, 2 );
|
101 |
-
|
102 |
// IPN hook for paypal standard!
|
103 |
if ( class_exists( 'GFPayPal' ) ) {
|
104 |
add_action( 'gform_paypal_post_ipn', array( $this, 'paypal_track_form_post_ipn' ), 10, 2 );
|
@@ -116,7 +78,7 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
116 |
|
117 |
$paypal_feeds = $this->get_feeds_by_slug( 'gravityformspaypal', $form['id'] );
|
118 |
$has_paypal_feed = false;
|
119 |
-
|
120 |
foreach ( $paypal_feeds as $paypal_feed ){
|
121 |
if ( $paypal_feed['is_active'] && $this->is_feed_condition_met( $paypal_feed, $form, $entry ) ){
|
122 |
$has_paypal_feed = true;
|
@@ -141,21 +103,13 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
141 |
* @return bool Returns true if UA ID is loaded, false otherwise
|
142 |
*/
|
143 |
private function load_ua_settings() {
|
144 |
-
$gravity_forms_add_on_settings = get_option( 'gravityformsaddon_gravity-forms-event-tracking_settings', array() );
|
145 |
-
|
146 |
-
$this->ua_id = $ua_id = false;
|
147 |
|
148 |
-
$ua_id =
|
149 |
-
|
150 |
-
$
|
151 |
-
|
152 |
-
if ( preg_match( $ua_regex, $ua_id ) ) {
|
153 |
-
$this->ua_id = $ua_id;
|
154 |
return true;
|
155 |
}
|
156 |
-
|
157 |
-
if ( ! $this->ua_id )
|
158 |
-
return false;
|
159 |
}
|
160 |
|
161 |
/**
|
@@ -173,16 +127,6 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
173 |
}
|
174 |
}
|
175 |
|
176 |
-
/**
|
177 |
-
* Load the google measurement protocol PHP client.
|
178 |
-
*
|
179 |
-
* @since 1.4.0
|
180 |
-
*/
|
181 |
-
private function load_measurement_client() {
|
182 |
-
require_once( 'vendor/ga-mp/src/Racecore/GATracking/Autoloader.php');
|
183 |
-
Racecore\GATracking\Autoloader::register( dirname(__FILE__) . '/vendor/ga-mp/src/' );
|
184 |
-
}
|
185 |
-
|
186 |
/**
|
187 |
* Get data required for processing
|
188 |
* @param array $feed feed
|
@@ -203,6 +147,8 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
203 |
|
204 |
// Store everything we need for later
|
205 |
$ga_event_data = array(
|
|
|
|
|
206 |
'ga_cookie' => $ga_cookie,
|
207 |
'document_location' => $document_location,
|
208 |
'document_title' => $document_title,
|
@@ -305,11 +251,11 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
305 |
* @param array $form Gravity Forms form object
|
306 |
*/
|
307 |
private function push_event( $entry, $form, $ga_event_data ) {
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
* Filter: gform_ua_ids
|
314 |
*
|
315 |
* Filter all outgoing UA IDs to send events to
|
@@ -320,12 +266,12 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
320 |
* @param object $form Gravity Form form object
|
321 |
* @param object $entry Gravity Form Entry Object
|
322 |
*/
|
323 |
-
|
324 |
-
|
325 |
if ( !is_array( $google_analytics_codes ) || empty( $google_analytics_codes ) ) return;
|
326 |
-
|
327 |
$event = new \Racecore\GATracking\Tracking\Event();
|
328 |
-
|
329 |
// Set some defaults
|
330 |
$event->setDocumentPath( str_replace( home_url(), '', $entry[ 'source_url' ] ) );
|
331 |
$event->setDocumentLocation( $ga_event_data['document_location'] );
|
@@ -333,58 +279,129 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
333 |
|
334 |
// Set our event object variables
|
335 |
/**
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
$
|
|
|
|
|
347 |
/**
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
$
|
|
|
|
|
359 |
/**
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
$
|
371 |
-
|
|
|
372 |
/**
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
|
|
383 |
// Event value must be a valid float!
|
384 |
$event_value = GFCommon::to_number( $event_value );
|
385 |
$event->setEventValue( $event_value );
|
386 |
}
|
387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
//Push out the event to each UA code
|
389 |
foreach( $google_analytics_codes as $ua_code ) {
|
390 |
|
@@ -414,29 +431,6 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
414 |
return false;
|
415 |
}
|
416 |
|
417 |
-
/**
|
418 |
-
* Plugin settings fields
|
419 |
-
*
|
420 |
-
* @return array Array of plugin settings
|
421 |
-
*/
|
422 |
-
public function plugin_settings_fields() {
|
423 |
-
return array(
|
424 |
-
array(
|
425 |
-
'title' => __( 'Google Analytics', 'gravity-forms-google-analytics-event-tracking' ),
|
426 |
-
'description' => __( 'Enter your UA code (UA-XXXX-Y). Find it <a href="https://support.google.com/analytics/answer/1032385" target="_blank">using this guide</a>.', 'gravity-forms-google-analytics-event-tracking' ),
|
427 |
-
'fields' => array(
|
428 |
-
array(
|
429 |
-
'name' => 'gravity_forms_event_tracking_ua',
|
430 |
-
'label' => __( 'UA Tracking ID', 'gravity-forms-google-analytics-event-tracking' ),
|
431 |
-
'type' => 'text',
|
432 |
-
'class' => 'medium',
|
433 |
-
'tooltip' => 'UA-XXXX-Y',
|
434 |
-
),
|
435 |
-
)
|
436 |
-
),
|
437 |
-
);
|
438 |
-
}
|
439 |
-
|
440 |
//---------- Form Settings Pages --------------------------
|
441 |
|
442 |
/**
|
@@ -446,7 +440,7 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
446 |
* @return string Form Settings Title
|
447 |
*/
|
448 |
public function feed_settings_title() {
|
449 |
-
return __( '
|
450 |
}
|
451 |
|
452 |
public function maybe_save_feed_settings( $feed_id, $form_id ) {
|
@@ -543,7 +537,7 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
543 |
),
|
544 |
),
|
545 |
array(
|
546 |
-
"title" => __( '
|
547 |
"fields" => array(
|
548 |
array(
|
549 |
"label" => "",
|
@@ -636,99 +630,4 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
636 |
);
|
637 |
}
|
638 |
|
639 |
-
//-------------- Setup ---------------
|
640 |
-
|
641 |
-
/**
|
642 |
-
* Upgrading functions
|
643 |
-
*
|
644 |
-
* @since 1.5.0
|
645 |
-
*/
|
646 |
-
public function upgrade( $previous_version ) {
|
647 |
-
|
648 |
-
// If the version is below 1.5.0, we need to move the form specific settings
|
649 |
-
if ( version_compare( $previous_version, "1.5.0" ) == -1 ) {
|
650 |
-
$forms = GFAPI::get_forms( true );
|
651 |
-
|
652 |
-
foreach ( $forms as $form ) {
|
653 |
-
$this->upgrade_old_form_settings( $form );
|
654 |
-
}
|
655 |
-
}
|
656 |
-
|
657 |
-
// If the version is below 1.6.0, we need to convert any form settings to a feed
|
658 |
-
if ( version_compare( $previous_version, "1.6.0" ) == -1 ) {
|
659 |
-
$forms = GFAPI::get_forms( true );
|
660 |
-
|
661 |
-
foreach ( $forms as $form ) {
|
662 |
-
$this->upgrade_settings_to_feed( $form );
|
663 |
-
}
|
664 |
-
}
|
665 |
-
|
666 |
-
}
|
667 |
-
|
668 |
-
/**
|
669 |
-
* Upgrade old settings created prior to new settings tab
|
670 |
-
*
|
671 |
-
* @since 1.5.0
|
672 |
-
* @param array $form GF Form Object Array
|
673 |
-
*/
|
674 |
-
public function upgrade_old_form_settings( $form ) {
|
675 |
-
$settings = array( 'gaEventCategory', 'gaEventAction', 'gaEventLabel', 'gaEventValue' );
|
676 |
-
|
677 |
-
foreach( $settings as $key => $setting ) {
|
678 |
-
if ( isset( $form[ $setting ] ) && ( ! isset( $form[ $this->_slug ] ) || ! isset( $form[ $this->_slug ][ $setting ] ) || empty( $form[ $this->_slug ][ $setting ] ) ) ) {
|
679 |
-
$form[ $this->_slug ][ $setting ] = $form[ $setting ];
|
680 |
-
}
|
681 |
-
unset( $form[ $setting ] );
|
682 |
-
}
|
683 |
-
|
684 |
-
GFFormsModel::update_form_meta( $form['id'], $form );
|
685 |
-
}
|
686 |
-
|
687 |
-
/**
|
688 |
-
* Upgrade settings and convert them into a feed
|
689 |
-
*
|
690 |
-
* @since 1.6.0
|
691 |
-
* @param array $form GF Form object Array
|
692 |
-
*/
|
693 |
-
public function upgrade_settings_to_feed( $form ) {
|
694 |
-
if ( isset( $form['gravity-forms-event-tracking'] ) && $previous_settings = $form['gravity-forms-event-tracking'] ) {
|
695 |
-
|
696 |
-
$field_names = array( 'gaEventCategory', 'gaEventAction', 'gaEventLabel', 'gaEventValue' );
|
697 |
-
|
698 |
-
$previous_was_setup = false;
|
699 |
-
|
700 |
-
$previous_was_enabled = isset( $previous_settings['gaEventTrackingDisabled'] ) ? ! $previous_settings['gaEventTrackingDisabled'] : true;
|
701 |
-
|
702 |
-
$settings = array();
|
703 |
-
|
704 |
-
foreach ($field_names as $field_name) {
|
705 |
-
if ( isset( $previous_settings[ $field_name ] ) && $previous_settings[ $field_name ] ) {
|
706 |
-
$settings[ $field_name ] = $previous_settings[ $field_name ];
|
707 |
-
$previous_was_setup = true;
|
708 |
-
}
|
709 |
-
|
710 |
-
unset( $form['gravity-forms-event-tracking'] );
|
711 |
-
|
712 |
-
GFFormsModel::update_form_meta( $form['id'], $form );
|
713 |
-
}
|
714 |
-
|
715 |
-
if ( ! $previous_was_setup && ! $previous_was_enabled ) {
|
716 |
-
return;
|
717 |
-
}
|
718 |
-
|
719 |
-
$settings['feedName'] = __( 'Event Tracking Feed', 'gravity-forms-google-analytics-event-tracking' );
|
720 |
-
|
721 |
-
$feed_id = $this->save_feed_settings( 0, $form['id'], $settings );
|
722 |
-
|
723 |
-
if ( ! $previous_was_enabled ) {
|
724 |
-
$this->update_feed_active( $feed_id, false );
|
725 |
-
}
|
726 |
-
|
727 |
-
}
|
728 |
-
else {
|
729 |
-
return;
|
730 |
-
}
|
731 |
-
|
732 |
-
}
|
733 |
-
|
734 |
}
|
9 |
* @copyright 2014 Nathan Marks
|
10 |
*/
|
11 |
|
|
|
12 |
GFForms::include_feed_addon_framework();
|
13 |
|
14 |
+
class GFGAET_Submission_Feeds extends GFFeedAddOn {
|
15 |
|
16 |
+
protected $_version = "2.0.0";
|
17 |
protected $_min_gravityforms_version = "1.8.20";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
protected $_slug = "gravity-forms-event-tracking";
|
19 |
protected $_path = "gravity-forms-google-analytics-event-tracking/gravity-forms-event-tracking.php";
|
20 |
protected $_full_path = __FILE__;
|
|
|
21 |
protected $_title = "Gravity Forms Google Analytics Event Tracking";
|
22 |
+
protected $_short_title = "Submission Tracking";
|
23 |
|
24 |
// Members plugin integration
|
25 |
protected $_capabilities = array( 'gravityforms_event_tracking', 'gravityforms_event_tracking_uninstall' );
|
35 |
|
36 |
public static function get_instance() {
|
37 |
if ( self::$_instance == null ) {
|
38 |
+
self::$_instance = new self();
|
39 |
}
|
40 |
|
41 |
return self::$_instance;
|
46 |
* See comment above for explanation.
|
47 |
*/
|
48 |
public function init() {
|
49 |
+
parent::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Public facing init
|
54 |
*
|
55 |
+
* @since 2.0.0
|
56 |
*/
|
57 |
public function init_frontend() {
|
58 |
|
59 |
parent::init_frontend();
|
|
|
|
|
|
|
60 |
|
61 |
+
require_once( 'vendor/ga-mp/src/Racecore/GATracking/Autoloader.php');
|
62 |
+
Racecore\GATracking\Autoloader::register( dirname(__FILE__) . '/vendor/ga-mp/src/' );
|
63 |
+
|
|
|
|
|
64 |
// IPN hook for paypal standard!
|
65 |
if ( class_exists( 'GFPayPal' ) ) {
|
66 |
add_action( 'gform_paypal_post_ipn', array( $this, 'paypal_track_form_post_ipn' ), 10, 2 );
|
78 |
|
79 |
$paypal_feeds = $this->get_feeds_by_slug( 'gravityformspaypal', $form['id'] );
|
80 |
$has_paypal_feed = false;
|
81 |
+
|
82 |
foreach ( $paypal_feeds as $paypal_feed ){
|
83 |
if ( $paypal_feed['is_active'] && $this->is_feed_condition_met( $paypal_feed, $form, $entry ) ){
|
84 |
$has_paypal_feed = true;
|
103 |
* @return bool Returns true if UA ID is loaded, false otherwise
|
104 |
*/
|
105 |
private function load_ua_settings() {
|
|
|
|
|
|
|
106 |
|
107 |
+
$this->ua_id = $ua_id = GFGAET::get_ua_code();
|
108 |
+
|
109 |
+
if ( false !== $this->ua_id ) {
|
|
|
|
|
|
|
110 |
return true;
|
111 |
}
|
112 |
+
return false;
|
|
|
|
|
113 |
}
|
114 |
|
115 |
/**
|
127 |
}
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
/**
|
131 |
* Get data required for processing
|
132 |
* @param array $feed feed
|
147 |
|
148 |
// Store everything we need for later
|
149 |
$ga_event_data = array(
|
150 |
+
'feed_id' => $feed['id'],
|
151 |
+
'entry_id' => $entry['id'],
|
152 |
'ga_cookie' => $ga_cookie,
|
153 |
'document_location' => $document_location,
|
154 |
'document_title' => $document_title,
|
251 |
* @param array $form Gravity Forms form object
|
252 |
*/
|
253 |
private function push_event( $entry, $form, $ga_event_data ) {
|
254 |
+
|
255 |
+
//Get all analytics codes to send
|
256 |
+
$google_analytics_codes = $this->get_ua_codes( $ga_event_data[ 'gaEventUA' ], $this->get_ga_id() );
|
257 |
+
|
258 |
+
/**
|
259 |
* Filter: gform_ua_ids
|
260 |
*
|
261 |
* Filter all outgoing UA IDs to send events to
|
266 |
* @param object $form Gravity Form form object
|
267 |
* @param object $entry Gravity Form Entry Object
|
268 |
*/
|
269 |
+
$google_analytics_codes = apply_filters( 'gform_ua_ids', $google_analytics_codes, $form, $entry );
|
270 |
+
|
271 |
if ( !is_array( $google_analytics_codes ) || empty( $google_analytics_codes ) ) return;
|
272 |
+
|
273 |
$event = new \Racecore\GATracking\Tracking\Event();
|
274 |
+
|
275 |
// Set some defaults
|
276 |
$event->setDocumentPath( str_replace( home_url(), '', $entry[ 'source_url' ] ) );
|
277 |
$event->setDocumentLocation( $ga_event_data['document_location'] );
|
279 |
|
280 |
// Set our event object variables
|
281 |
/**
|
282 |
+
* Filter: gform_event_category
|
283 |
+
*
|
284 |
+
* Filter the event category dynamically
|
285 |
+
*
|
286 |
+
* @since 1.6.5
|
287 |
+
*
|
288 |
+
* @param string $category Event Category
|
289 |
+
* @param object $form Gravity Form form object
|
290 |
+
* @param object $entry Gravity Form Entry Object
|
291 |
+
*/
|
292 |
+
$event_category = apply_filters( 'gform_event_category', $ga_event_data['gaEventCategory'], $form, $entry );
|
293 |
+
$event->setEventCategory( $event_category );
|
294 |
+
|
295 |
/**
|
296 |
+
* Filter: gform_event_action
|
297 |
+
*
|
298 |
+
* Filter the event action dynamically
|
299 |
+
*
|
300 |
+
* @since 1.6.5
|
301 |
+
*
|
302 |
+
* @param string $action Event Action
|
303 |
+
* @param object $form Gravity Form form object
|
304 |
+
* @param object $entry Gravity Form Entry Object
|
305 |
+
*/
|
306 |
+
$event_action = apply_filters( 'gform_event_action', $ga_event_data['gaEventAction'], $form, $entry );
|
307 |
+
$event->setEventAction( $event_action );
|
308 |
+
|
309 |
/**
|
310 |
+
* Filter: gform_event_label
|
311 |
+
*
|
312 |
+
* Filter the event label dynamically
|
313 |
+
*
|
314 |
+
* @since 1.6.5
|
315 |
+
*
|
316 |
+
* @param string $label Event Label
|
317 |
+
* @param object $form Gravity Form form object
|
318 |
+
* @param object $entry Gravity Form Entry Object
|
319 |
+
*/
|
320 |
+
$event_label = apply_filters( 'gform_event_label', $ga_event_data['gaEventLabel'], $form, $entry );
|
321 |
+
$event->setEventLabel( $event_label );
|
322 |
+
|
323 |
/**
|
324 |
+
* Filter: gform_event_value
|
325 |
+
*
|
326 |
+
* Filter the event value dynamically
|
327 |
+
*
|
328 |
+
* @since 1.6.5
|
329 |
+
*
|
330 |
+
* @param object $form Gravity Form form object
|
331 |
+
* @param object $entry Gravity Form Entry Object
|
332 |
+
*/
|
333 |
+
$event_value = apply_filters( 'gform_event_value', $ga_event_data['gaEventValue'], $form, $entry );
|
334 |
+
if ( $event_value ) {
|
335 |
// Event value must be a valid float!
|
336 |
$event_value = GFCommon::to_number( $event_value );
|
337 |
$event->setEventValue( $event_value );
|
338 |
}
|
339 |
|
340 |
+
$feed_id = absint( $ga_event_data[ 'feed_id' ] );
|
341 |
+
$entry_id = $entry['id'];
|
342 |
+
|
343 |
+
if ( GFGAET::is_ga_only() ) {
|
344 |
+
$count = 1;
|
345 |
+
?>
|
346 |
+
<script>
|
347 |
+
<?php
|
348 |
+
foreach( $google_analytics_codes as $ua_code ) {
|
349 |
+
?>
|
350 |
+
var feed_submission = sessionStorage.getItem('feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>');
|
351 |
+
if ( null == feed_submission ) {
|
352 |
+
if ( typeof window.parent.ga == 'undefined' ) {
|
353 |
+
if ( typeof window.parent.__gaTracker != 'undefined' ) {
|
354 |
+
window.parent.ga = window.parent.__gaTracker;
|
355 |
+
}
|
356 |
+
}
|
357 |
+
if ( typeof window.parent.ga != 'undefined' ) {
|
358 |
+
|
359 |
+
// Try to get original UA code from third-party plugins or tag manager
|
360 |
+
var default_ua_code = null;
|
361 |
+
window.parent.ga(function(tracker) {
|
362 |
+
default_ua_code = tracker.get('trackingId');
|
363 |
+
});
|
364 |
+
|
365 |
+
// If UA code matches, use that tracker
|
366 |
+
if ( default_ua_code == '<?php echo esc_js( $ua_code ); ?>' ) {
|
367 |
+
window.parent.ga( 'send', 'event', '<?php echo esc_js( $event_category ); ?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>' );
|
368 |
+
} else {
|
369 |
+
// UA code doesn't match, use another tracker
|
370 |
+
window.parent.ga( 'create', '<?php echo esc_js( $ua_code ); ?>', 'auto', 'GTGAET_Tracker<?php echo absint( $count ); ?>' );
|
371 |
+
window.parent.ga( 'GTGAET_Tracker<?php echo absint( $count ); ?>.send', 'event', '<?php echo esc_js( $event_category );?>', '<?php echo esc_js( $event_action ); ?>', '<?php echo esc_js( $event_label ); ?>' );
|
372 |
+
}
|
373 |
+
|
374 |
+
sessionStorage.setItem('feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>', true );
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
<?php
|
379 |
+
$count += 1;
|
380 |
+
}
|
381 |
+
?>
|
382 |
+
</script>
|
383 |
+
<?php
|
384 |
+
return;
|
385 |
+
} else if ( GFGAET::is_gtm_only() ) {
|
386 |
+
?>
|
387 |
+
<script>
|
388 |
+
var form_submission = sessionStorage.getItem('feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>');
|
389 |
+
if ( null == form_submission ) {
|
390 |
+
if ( typeof( window.parent.dataLayer ) != 'undefined' ) {
|
391 |
+
window.parent.dataLayer.push({'event': 'GFTrackEvent',
|
392 |
+
'GFTrackCategory':'<?php echo esc_js( $event_category ); ?>',
|
393 |
+
'GFTrackAction':'<?php echo esc_js( $event_action ); ?>s',
|
394 |
+
'GFTrackLabel':'<?php echo esc_js( $event_label ); ?>',
|
395 |
+
'GFEntryData':<?php echo json_encode( $entry ); ?>
|
396 |
+
});
|
397 |
+
sessionStorage.setItem("feed_<?php echo absint( $feed_id ); ?>_entry_<?php echo absint( $entry[ 'id' ] ); ?>", "true");
|
398 |
+
}
|
399 |
+
}
|
400 |
+
</script>
|
401 |
+
<?php
|
402 |
+
return;
|
403 |
+
}
|
404 |
+
|
405 |
//Push out the event to each UA code
|
406 |
foreach( $google_analytics_codes as $ua_code ) {
|
407 |
|
431 |
return false;
|
432 |
}
|
433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
//---------- Form Settings Pages --------------------------
|
435 |
|
436 |
/**
|
440 |
* @return string Form Settings Title
|
441 |
*/
|
442 |
public function feed_settings_title() {
|
443 |
+
return __( 'Submission Tracking Settings', 'gravity-forms-google-analytics-event-tracking' );
|
444 |
}
|
445 |
|
446 |
public function maybe_save_feed_settings( $feed_id, $form_id ) {
|
537 |
),
|
538 |
),
|
539 |
array(
|
540 |
+
"title" => __( 'Submission Tracking Settings', 'gravity-forms-google-analytics-event-tracking' ),
|
541 |
"fields" => array(
|
542 |
array(
|
543 |
"label" => "",
|
630 |
);
|
631 |
}
|
632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
}
|
includes/GFGAET_Tag_Manager.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GFGAET_Tag_Manager {
|
3 |
+
/**
|
4 |
+
* Holds the class instance.
|
5 |
+
*
|
6 |
+
* @since 2.0.0
|
7 |
+
* @access private
|
8 |
+
*/
|
9 |
+
private static $instance = null;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Retrieve a class instance.
|
13 |
+
*
|
14 |
+
* @since 2.0.0
|
15 |
+
*/
|
16 |
+
public static function get_instance() {
|
17 |
+
if ( null == self::$instance ) {
|
18 |
+
self::$instance = new self;
|
19 |
+
}
|
20 |
+
return self::$instance;
|
21 |
+
} //end get_instance
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Class constructor.
|
25 |
+
*
|
26 |
+
* @since 2.0.0
|
27 |
+
*/
|
28 |
+
private function __construct() {
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Initialize the tag manager push.
|
34 |
+
*
|
35 |
+
* @since 2.0.0
|
36 |
+
*
|
37 |
+
* @param array $entry The entry array
|
38 |
+
* @param array $form The form array
|
39 |
+
*/
|
40 |
+
public function send( $entry, $form ) {
|
41 |
+
if ( GFGAET::is_js_only() ) {
|
42 |
+
?>
|
43 |
+
<script>
|
44 |
+
var form_submission = sessionStorage.getItem('entry_<?php echo absint( $entry[ 'id' ] ); ?>');
|
45 |
+
if ( null == form_submission ) {
|
46 |
+
if ( typeof( dataLayer ) != 'undefined' ) {
|
47 |
+
dataLayer.push({'event': 'GFTrackEvent',
|
48 |
+
'GFTrackCategory':'form',
|
49 |
+
'GFTrackAction':'submission',
|
50 |
+
'GFTrackLabel':'{{<?php echo esc_js( $form['title'] ); ?>}}::{{<?php echo esc_js( $entry['id'] ); ?>}}',
|
51 |
+
'GFEntryData':<?php echo json_encode( $entry ); ?>
|
52 |
+
});
|
53 |
+
sessionStorage.setItem("entry_<?php echo absint( $entry[ 'id' ] ); ?>", "true");
|
54 |
+
}
|
55 |
+
}
|
56 |
+
</script>
|
57 |
+
<?php
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
includes/GFGAET_UA.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
GFForms::include_addon_framework();
|
3 |
+
class GFGAET_UA extends GFAddOn {
|
4 |
+
protected $_version = '2.0';
|
5 |
+
protected $_min_gravityforms_version = '1.8.20';
|
6 |
+
protected $_slug = 'GFGAET_UA';
|
7 |
+
protected $_path = 'gravity-forms-google-analytics-event-tracking/gravity-forms-event-tracking.php';
|
8 |
+
protected $_full_path = __FILE__;
|
9 |
+
protected $_title = 'Gravity Forms Google Analytics Event Tracking';
|
10 |
+
protected $_short_title = 'Event Tracking';
|
11 |
+
|
12 |
+
private static $_instance = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Returns an instance of this class, and stores it in the $_instance property.
|
16 |
+
*
|
17 |
+
* @return object $_instance An instance of this class.
|
18 |
+
*/
|
19 |
+
public static function get_instance() {
|
20 |
+
if ( self::$_instance == null ) {
|
21 |
+
self::$_instance = new self();
|
22 |
+
}
|
23 |
+
|
24 |
+
return self::$_instance;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function init() {
|
28 |
+
parent::init();
|
29 |
+
|
30 |
+
// Migrate old GA Code over to new add-on
|
31 |
+
$ga_options = get_option( 'gravityformsaddon_GFGAET_UA_settings', false );
|
32 |
+
if ( ! $ga_options ) {
|
33 |
+
$old_ga_option = get_option( 'gravityformsaddon_gravity-forms-event-tracking_settings', false );
|
34 |
+
if ( $old_ga_option ) {
|
35 |
+
update_option( 'gravityformsaddon_GFGAET_UA_settings', $old_ga_option );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Plugin settings fields
|
43 |
+
*
|
44 |
+
* @return array Array of plugin settings
|
45 |
+
*/
|
46 |
+
public function plugin_settings_fields() {
|
47 |
+
return array(
|
48 |
+
array(
|
49 |
+
'title' => __( 'Google Analytics', 'gravity-forms-google-analytics-event-tracking' ),
|
50 |
+
'description' => __( 'Need help? <a target="_blank" href="https://bigwing.com/nest/gravity-forms-event-tracking-google-analytics/">See our guide</a>.', 'gravity-forms-google-analytics-event-tracking' ),
|
51 |
+
'fields' => array(
|
52 |
+
array(
|
53 |
+
'name' => 'gravity_forms_event_tracking_ua',
|
54 |
+
'tooltip' => __( 'Enter your UA code (UA-XXXX-Y) Find it <a href="https://support.google.com/analytics/answer/1032385" target="_blank">using this guide</a>.', 'gravity-forms-google-analytics-event-tracking' ),
|
55 |
+
'label' => __( 'UA Tracking ID', 'gravity-forms-google-analytics-event-tracking' ),
|
56 |
+
'type' => 'text',
|
57 |
+
'class' => 'small',
|
58 |
+
|
59 |
+
),
|
60 |
+
)
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'title' => __( 'Advanced', 'gravity-forms-google-analytics-event-tracking' ),
|
64 |
+
'description' => __( 'By default, events are sent using the measurement protocol. You can change to using pure Google Analytics and Google Tag Manager if your forms are Ajax only.', 'gravity-forms-google-analytics-event-tracking' ),
|
65 |
+
'fields' => array(
|
66 |
+
array(
|
67 |
+
'type' => 'radio',
|
68 |
+
'name' => 'mode',
|
69 |
+
'horizontal' => false,
|
70 |
+
'default_value' => 'gmp',
|
71 |
+
'label' => 'How would you like to send events?',
|
72 |
+
'choices' => array(
|
73 |
+
array(
|
74 |
+
'name' => 'ga_on',
|
75 |
+
'tooltip' => esc_html__( 'Forms must be Ajax only', 'sometextdomain' ),
|
76 |
+
'label' => esc_html__( 'Google Analytics (Ajax only)', 'gravity-forms-google-analytics-event-tracking' ),
|
77 |
+
'value' => 'ga'
|
78 |
+
),
|
79 |
+
array(
|
80 |
+
'name' => 'gtm_on',
|
81 |
+
'tooltip' => esc_html__( 'Forms must be Ajax only', 'gravity-forms-google-analytics-event-tracking' ),
|
82 |
+
'label' => esc_html__( 'Google Tag Manager (Ajax only)', 'gravity-forms-google-analytics-event-tracking' ),
|
83 |
+
'value' => 'gtm'
|
84 |
+
),
|
85 |
+
array(
|
86 |
+
'name' => 'gmp_on',
|
87 |
+
'tooltip' => esc_html__( 'Events will be sent using the measurement protocol.', 'sometextdomain' ),
|
88 |
+
'label' => esc_html__( 'Measurement Protocol (Default)', 'gravity-forms-google-analytics-event-tracking' ),
|
89 |
+
'value' => 'gmp'
|
90 |
+
),
|
91 |
+
),
|
92 |
+
),
|
93 |
+
array(
|
94 |
+
'type' => 'radio',
|
95 |
+
'name' => 'ajax_only',
|
96 |
+
'horizontal' => false,
|
97 |
+
'default_value' => 'off',
|
98 |
+
'label' => 'Make all forms Ajax only?',
|
99 |
+
'choices' => array(
|
100 |
+
array(
|
101 |
+
'name' => 'ajax_on',
|
102 |
+
'label' => esc_html__( 'Ajax only', 'gravity-forms-google-analytics-event-tracking' ),
|
103 |
+
'value' => 'on'
|
104 |
+
),
|
105 |
+
array(
|
106 |
+
'name' => 'ajax_off',
|
107 |
+
'label' => esc_html__( 'Default', 'gravity-forms-google-analytics-event-tracking' ),
|
108 |
+
'value' => 'off'
|
109 |
+
),
|
110 |
+
),
|
111 |
+
),
|
112 |
+
),
|
113 |
+
)
|
114 |
+
);
|
115 |
+
}
|
116 |
+
}
|
includes/vendor/ga-mp/src/Racecore/GATracking/Autoloader.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Client/AbstractClientAdapter.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Client;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Exception;
|
6 |
-
use Racecore\GATracking\Request;
|
7 |
-
|
8 |
-
class AbstractClientAdapter implements ClientAdapterInterface
|
9 |
-
{
|
10 |
-
private $options = array();
|
11 |
-
|
12 |
-
public function __construct($options = array())
|
13 |
-
{
|
14 |
-
$this->options = $options;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Set Options
|
19 |
-
*
|
20 |
-
* @param $options
|
21 |
-
* @throws Exception\InvalidArgumentException
|
22 |
-
*/
|
23 |
-
public function setOptions($options)
|
24 |
-
{
|
25 |
-
if (!is_array($options)) {
|
26 |
-
throw new Exception\InvalidArgumentException(sprintf(
|
27 |
-
'[%s] expects array; received [%s]',
|
28 |
-
__METHOD__,
|
29 |
-
gettype($options)
|
30 |
-
));
|
31 |
-
}
|
32 |
-
|
33 |
-
$this->options = $options;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Return Options
|
38 |
-
* @return array
|
39 |
-
*/
|
40 |
-
public function getOptions()
|
41 |
-
{
|
42 |
-
return $this->options;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Return Single Option
|
47 |
-
* @param $key
|
48 |
-
* @return null|mixed
|
49 |
-
*/
|
50 |
-
public function getOption($key)
|
51 |
-
{
|
52 |
-
if (!isset($this->options[$key])) {
|
53 |
-
return null;
|
54 |
-
}
|
55 |
-
|
56 |
-
return $this->options[$key];
|
57 |
-
}
|
58 |
-
|
59 |
-
public function send($url, Request\TrackingRequestCollection $collection)
|
60 |
-
{
|
61 |
-
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Client/Adapter/Socket.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Client\Adapter;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Client;
|
6 |
-
use Racecore\GATracking\Exception;
|
7 |
-
use Racecore\GATracking\Request;
|
8 |
-
|
9 |
-
class Socket extends Client\AbstractClientAdapter
|
10 |
-
{
|
11 |
-
const READ_TIMEOUT = 3;
|
12 |
-
const READ_BUFFER = 8192;
|
13 |
-
|
14 |
-
private $connection = null;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Create Connection to the Google Server
|
18 |
-
* @param $endpoint
|
19 |
-
* @throws Exception\EndpointServerException
|
20 |
-
*/
|
21 |
-
private function createConenction($endpoint)
|
22 |
-
{
|
23 |
-
// port
|
24 |
-
$port = $this->getOption('ssl') == true ? 443 : 80;
|
25 |
-
|
26 |
-
$connection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
27 |
-
socket_connect($connection, $endpoint['host'], $port);
|
28 |
-
socket_set_option($connection, SOL_SOCKET, SO_RCVTIMEO, array('sec' => self::READ_TIMEOUT, 'usec' => 0));
|
29 |
-
|
30 |
-
if ($this->getOption('async')) {
|
31 |
-
socket_set_nonblock($connection);
|
32 |
-
}
|
33 |
-
|
34 |
-
if (!$connection) {
|
35 |
-
throw new Exception\EndpointServerException('Analytics Host not reachable! Error:');
|
36 |
-
}
|
37 |
-
|
38 |
-
$this->connection = $connection;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Write the connection header
|
43 |
-
* @param $endpoint
|
44 |
-
* @param Request\TrackingRequest $request
|
45 |
-
* @param bool $lastData
|
46 |
-
* @return string
|
47 |
-
* @throws Exception\EndpointServerException
|
48 |
-
*/
|
49 |
-
private function writeHeader($endpoint, Request\TrackingRequest $request, $lastData = false)
|
50 |
-
{
|
51 |
-
// create data
|
52 |
-
$payloadString = http_build_query($request->getPayload());
|
53 |
-
$payloadLength = strlen($payloadString);
|
54 |
-
|
55 |
-
$header = 'POST ' . $endpoint['path'] . ' HTTP/1.1' . "\r\n" .
|
56 |
-
'Host: ' . $endpoint['host'] . "\r\n" .
|
57 |
-
'User-Agent: Google-Measurement-PHP-Client' . "\r\n" .
|
58 |
-
'Content-Length: ' . $payloadLength . "\r\n" .
|
59 |
-
($lastData ? 'Connection: Close' . "\r\n" : '') . "\r\n";
|
60 |
-
|
61 |
-
// fwrite + check if fwrite was ok
|
62 |
-
if (!socket_write($this->connection, $header) || !socket_write($this->connection, $payloadString)) {
|
63 |
-
throw new Exception\EndpointServerException('Server closed connection unexpectedly');
|
64 |
-
}
|
65 |
-
|
66 |
-
return $header;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Read from the current connection
|
71 |
-
* @param Request\TrackingRequest $request
|
72 |
-
* @return array|false
|
73 |
-
*/
|
74 |
-
private function readConnection(Request\TrackingRequest $request)
|
75 |
-
{
|
76 |
-
// response
|
77 |
-
$response = '';
|
78 |
-
|
79 |
-
// receive response
|
80 |
-
do {
|
81 |
-
$out = @socket_read($this->connection, self::READ_BUFFER);
|
82 |
-
$response .= $out;
|
83 |
-
|
84 |
-
if (!$out || strlen($out) < self::READ_BUFFER) {
|
85 |
-
break;
|
86 |
-
}
|
87 |
-
} while (true);
|
88 |
-
|
89 |
-
// response
|
90 |
-
$responseContainer = explode("\r\n\r\n", $response, 2);
|
91 |
-
return explode("\r\n", $responseContainer[0]);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Send the Request Collection to a Server
|
96 |
-
* @param $url
|
97 |
-
* @param Request\TrackingRequestCollection $requestCollection
|
98 |
-
* @return Request\TrackingRequestCollection|void
|
99 |
-
* @throws Exception\EndpointServerException
|
100 |
-
*/
|
101 |
-
public function send($url, Request\TrackingRequestCollection $requestCollection)
|
102 |
-
{
|
103 |
-
// get endpoint
|
104 |
-
$endpoint = parse_url($url);
|
105 |
-
|
106 |
-
$this->createConenction($endpoint);
|
107 |
-
|
108 |
-
/** @var Request\TrackingRequest $request */
|
109 |
-
while ($requestCollection->valid()) {
|
110 |
-
$request = $requestCollection->current();
|
111 |
-
$requestCollection->next();
|
112 |
-
|
113 |
-
$this->writeHeader($endpoint, $request, !$requestCollection->valid());
|
114 |
-
$responseHeader = $this->readConnection($request);
|
115 |
-
|
116 |
-
$request->setResponseHeader($responseHeader);
|
117 |
-
}
|
118 |
-
// connection close
|
119 |
-
socket_close($this->connection);
|
120 |
-
|
121 |
-
return $requestCollection;
|
122 |
-
}
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Client/ClientAdapterInterface.php
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Client;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Request;
|
6 |
-
|
7 |
-
interface ClientAdapterInterface
|
8 |
-
{
|
9 |
-
public function __construct($options = array());
|
10 |
-
public function setOptions($options);
|
11 |
-
public function send($url, Request\TrackingRequestCollection $collection);
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception/EndpointServerException.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception/InvalidArgumentException.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Exception;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Exception;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Google Analytics Measurement PHP Class
|
9 |
-
* Licensed under the 3-clause BSD License.
|
10 |
-
* This source file is subject to the 3-clause BSD License that is
|
11 |
-
* bundled with this package in the LICENSE file. It is also available at
|
12 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
13 |
-
*
|
14 |
-
* Google Documentation
|
15 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
16 |
-
*
|
17 |
-
* @author Marco Rieger
|
18 |
-
* @email Rieger(at)racecore.de
|
19 |
-
* @git https://github.com/ins0
|
20 |
-
* @url http://www.racecore.de
|
21 |
-
* @package Racecore\GATracking\Exception
|
22 |
-
*/
|
23 |
-
class InvalidArgumentException extends Exception
|
24 |
-
{
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception/InvalidOptionException.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Exception;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Exception;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Google Analytics Measurement PHP Class
|
9 |
-
* Licensed under the 3-clause BSD License.
|
10 |
-
* This source file is subject to the 3-clause BSD License that is
|
11 |
-
* bundled with this package in the LICENSE file. It is also available at
|
12 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
13 |
-
*
|
14 |
-
* Google Documentation
|
15 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
16 |
-
*
|
17 |
-
* @author Marco Rieger
|
18 |
-
* @email Rieger(at)racecore.de
|
19 |
-
* @git https://github.com/ins0
|
20 |
-
* @url http://www.racecore.de
|
21 |
-
* @package Racecore\GATracking\Exception
|
22 |
-
*/
|
23 |
-
class InvalidOptionException extends Exception
|
24 |
-
{
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception/MissingConfigurationException.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Exception/MissingTrackingParameterException.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/GATracking.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Request/TrackingRequest.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Request;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Tracking;
|
6 |
-
|
7 |
-
class TrackingRequest
|
8 |
-
{
|
9 |
-
private $payload = array();
|
10 |
-
private $responseHeader = array();
|
11 |
-
|
12 |
-
public function __construct(array $payload = array())
|
13 |
-
{
|
14 |
-
$this->payload = $payload;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return array
|
19 |
-
*/
|
20 |
-
public function getPayload()
|
21 |
-
{
|
22 |
-
return $this->payload;
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @param array $payload
|
27 |
-
*/
|
28 |
-
public function setPayload($payload)
|
29 |
-
{
|
30 |
-
$this->payload = $payload;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @return mixed
|
35 |
-
*/
|
36 |
-
public function getResponseHeader()
|
37 |
-
{
|
38 |
-
return $this->responseHeader;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param mixed $responseHeader
|
43 |
-
*/
|
44 |
-
public function setResponseHeader($responseHeader)
|
45 |
-
{
|
46 |
-
$this->responseHeader = $responseHeader;
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Request/TrackingRequestCollection.php
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Request;
|
4 |
-
|
5 |
-
use Racecore\GATracking\Tracking;
|
6 |
-
|
7 |
-
class TrackingRequestCollection implements \Iterator
|
8 |
-
{
|
9 |
-
private $requestHolder = array();
|
10 |
-
|
11 |
-
public function add(TrackingRequest $request)
|
12 |
-
{
|
13 |
-
$this->requestHolder[] = $request;
|
14 |
-
}
|
15 |
-
|
16 |
-
public function addElements($array)
|
17 |
-
{
|
18 |
-
foreach ($array as $element) {
|
19 |
-
$this->add($element);
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
public function rewind()
|
24 |
-
{
|
25 |
-
reset($this->requestHolder);
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* {@inheritdoc}
|
30 |
-
*/
|
31 |
-
public function current()
|
32 |
-
{
|
33 |
-
return current($this->requestHolder);
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* {@inheritdoc}
|
38 |
-
*/
|
39 |
-
public function key()
|
40 |
-
{
|
41 |
-
return key($this->requestHolder);
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* {@inheritdoc}
|
46 |
-
*/
|
47 |
-
public function next()
|
48 |
-
{
|
49 |
-
return next($this->requestHolder);
|
50 |
-
}
|
51 |
-
|
52 |
-
public function prev()
|
53 |
-
{
|
54 |
-
return prev($this->requestHolder);
|
55 |
-
}
|
56 |
-
|
57 |
-
public function getIterator()
|
58 |
-
{
|
59 |
-
$this->rewind();
|
60 |
-
return $this;
|
61 |
-
}
|
62 |
-
|
63 |
-
public function valid()
|
64 |
-
{
|
65 |
-
return (bool) $this->current();
|
66 |
-
}
|
67 |
-
|
68 |
-
public function count()
|
69 |
-
{
|
70 |
-
return count($this->requestHolder);
|
71 |
-
}
|
72 |
-
|
73 |
-
public function indexOf($element)
|
74 |
-
{
|
75 |
-
return array_search($element, $this->requestHolder);
|
76 |
-
}
|
77 |
-
|
78 |
-
public function removeElement($element)
|
79 |
-
{
|
80 |
-
$key = $this->indexOf($element);
|
81 |
-
if ($key) {
|
82 |
-
unset($this->requestHolder[$key]);
|
83 |
-
return true;
|
84 |
-
}
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/AbstractTracking.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/App/Event.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/App/Screen.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Campaign.php
DELETED
@@ -1,233 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace Racecore\GATracking\Tracking;
|
3 |
-
|
4 |
-
use Racecore\GATracking\Exception\MissingTrackingParameterException;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Google Analytics Measurement PHP Class
|
8 |
-
* Licensed under the 3-clause BSD License.
|
9 |
-
* This source file is subject to the 3-clause BSD License that is
|
10 |
-
* bundled with this package in the LICENSE file. It is also available at
|
11 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
12 |
-
*
|
13 |
-
* Google Documentation
|
14 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
15 |
-
*
|
16 |
-
* @author Marco Rieger
|
17 |
-
* @email Rieger(at)racecore.de
|
18 |
-
* @git https://github.com/ins0
|
19 |
-
* @url http://www.racecore.de
|
20 |
-
* @package Racecore\GATracking\Tracking
|
21 |
-
*/
|
22 |
-
class Campaign extends Page
|
23 |
-
{
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Campaign Name
|
27 |
-
*
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
private $name;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Campaign Source
|
34 |
-
*
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
private $source;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Campaign Medium
|
41 |
-
*
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
private $medium;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Campaign Keywords
|
48 |
-
*
|
49 |
-
* @var array
|
50 |
-
*/
|
51 |
-
private $keywords = array();
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Campaign Content
|
55 |
-
*
|
56 |
-
* @var string
|
57 |
-
*/
|
58 |
-
private $content;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Campaign ID
|
62 |
-
*
|
63 |
-
* @var integer
|
64 |
-
*/
|
65 |
-
private $cid;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Sets the Campaign ID
|
69 |
-
*
|
70 |
-
* @param $cid
|
71 |
-
* @return $this
|
72 |
-
*/
|
73 |
-
public function setCampaignID($cid)
|
74 |
-
{
|
75 |
-
$this->cid = $cid;
|
76 |
-
return $this;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Returns the Campaign ID
|
81 |
-
*
|
82 |
-
* @return int
|
83 |
-
*/
|
84 |
-
public function getCampaignID()
|
85 |
-
{
|
86 |
-
return $this->cid;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Sets the Campaign Content Description
|
91 |
-
*
|
92 |
-
* @param $content
|
93 |
-
* @return $this
|
94 |
-
*/
|
95 |
-
public function setCampaignContent($content)
|
96 |
-
{
|
97 |
-
$this->content = $content;
|
98 |
-
return $this;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Gets the Campaign Content Description
|
103 |
-
*
|
104 |
-
* @return string
|
105 |
-
*/
|
106 |
-
public function getCampaignContent()
|
107 |
-
{
|
108 |
-
return $this->content;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Sets the Campaign Keywords
|
113 |
-
*
|
114 |
-
* @param $keywords
|
115 |
-
* @return $this
|
116 |
-
*/
|
117 |
-
public function setCampaignKeywords($keywords)
|
118 |
-
{
|
119 |
-
$this->keywords = $keywords;
|
120 |
-
return $this;
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Return the Campaign Keywords
|
125 |
-
*
|
126 |
-
* @return array
|
127 |
-
*/
|
128 |
-
public function getCampaignKeywords()
|
129 |
-
{
|
130 |
-
return $this->keywords;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Sets the Campaign Medium
|
135 |
-
*
|
136 |
-
* @param $medium
|
137 |
-
* @return $this
|
138 |
-
*/
|
139 |
-
public function setCampaignMedium($medium)
|
140 |
-
{
|
141 |
-
$this->medium = $medium;
|
142 |
-
return $this;
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Gets the Campaign Medium
|
147 |
-
*
|
148 |
-
* @return string
|
149 |
-
*/
|
150 |
-
public function getCampaignMedium()
|
151 |
-
{
|
152 |
-
return $this->medium;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Sets the Campaign Name
|
157 |
-
*
|
158 |
-
* @param $name
|
159 |
-
* @return $this
|
160 |
-
*/
|
161 |
-
public function setCampaignName($name)
|
162 |
-
{
|
163 |
-
$this->name = $name;
|
164 |
-
return $this;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Get the Campaign Name
|
169 |
-
*
|
170 |
-
* @return string
|
171 |
-
*/
|
172 |
-
public function getCampaignName()
|
173 |
-
{
|
174 |
-
return $this->name;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Sets the Campaign Source
|
179 |
-
*
|
180 |
-
* @param $source
|
181 |
-
* @return $this
|
182 |
-
*/
|
183 |
-
public function setCampaignSource($source)
|
184 |
-
{
|
185 |
-
$this->source = $source;
|
186 |
-
return $this;
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Get the Campaign Source
|
191 |
-
*
|
192 |
-
* @return string
|
193 |
-
*/
|
194 |
-
public function getCampaignSource()
|
195 |
-
{
|
196 |
-
return $this->source;
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Returns the Paket for Campaign Tracking
|
201 |
-
*
|
202 |
-
* @return array
|
203 |
-
* @throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
204 |
-
*/
|
205 |
-
public function getPaket()
|
206 |
-
{
|
207 |
-
|
208 |
-
$packet = parent::getPaket();
|
209 |
-
|
210 |
-
if (!$this->getCampaignName()) {
|
211 |
-
throw new MissingTrackingParameterException('Campaign Name musst be set');
|
212 |
-
}
|
213 |
-
|
214 |
-
if (!$this->getCampaignMedium()) {
|
215 |
-
throw new MissingTrackingParameterException('Campaign Medium musst be set');
|
216 |
-
}
|
217 |
-
|
218 |
-
if (!$this->getCampaignSource()) {
|
219 |
-
throw new MissingTrackingParameterException('Campaign Source musst be set');
|
220 |
-
}
|
221 |
-
|
222 |
-
return array_merge($packet, array(
|
223 |
-
'cn' => $this->getCampaignName(),
|
224 |
-
'cs' => $this->getCampaignSource(),
|
225 |
-
'cm' => $this->getCampaignMedium(),
|
226 |
-
'ck' => implode(';', $this->getCampaignKeywords()),
|
227 |
-
'cc' => $this->getCampaignContent(),
|
228 |
-
'ci' => $this->getCampaignID()
|
229 |
-
));
|
230 |
-
}
|
231 |
-
|
232 |
-
|
233 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Item.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Event.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Exception.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Factory.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Racecore\GATracking\Tracking;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Google Analytics Measurement PHP Class
|
7 |
-
* Licensed under the 3-clause BSD License.
|
8 |
-
* This source file is subject to the 3-clause BSD License that is
|
9 |
-
* bundled with this package in the LICENSE file. It is also available at
|
10 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
11 |
-
*
|
12 |
-
* Google Documentation
|
13 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
14 |
-
*
|
15 |
-
* @author Marco Rieger
|
16 |
-
* @email Rieger(at)racecore.de
|
17 |
-
* @git https://github.com/ins0
|
18 |
-
* @url http://www.racecore.de
|
19 |
-
* @package Racecore\GATracking\Tracking
|
20 |
-
*/
|
21 |
-
class Factory extends AbstractTracking
|
22 |
-
{
|
23 |
-
private $payload = array();
|
24 |
-
|
25 |
-
public function __construct($payload)
|
26 |
-
{
|
27 |
-
$this->payload = $payload;
|
28 |
-
}
|
29 |
-
|
30 |
-
public function createPackage()
|
31 |
-
{
|
32 |
-
// nothing
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Returns the payload for a custom tracking package
|
37 |
-
* @return array
|
38 |
-
*/
|
39 |
-
public function getPackage()
|
40 |
-
{
|
41 |
-
return $this->payload;
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Page.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/Social.php
CHANGED
File without changes
|
includes/vendor/ga-mp/src/Racecore/GATracking/Tracking/User/Timing.php
CHANGED
File without changes
|
index.php
CHANGED
File without changes
|
languages/gravity-forms-google-analytics-event-tracking.pot
CHANGED
File without changes
|
languages/index.php
CHANGED
File without changes
|
uninstall.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Fired when the plugin is uninstalled.
|
4 |
-
*
|
5 |
-
* @package Plugin_Name
|
6 |
-
* @author Your Name <email@example.com>
|
7 |
-
* @license GPL-2.0+
|
8 |
-
* @link http://example.com
|
9 |
-
* @copyright 2014 Your Name or Company Name
|
10 |
-
*/
|
11 |
-
|
12 |
-
// If uninstall not called from WordPress, then exit
|
13 |
-
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
14 |
-
exit;
|
15 |
-
}
|
16 |
-
|
17 |
-
global $wpdb;
|
18 |
-
|
19 |
-
if ( is_multisite() ) {
|
20 |
-
|
21 |
-
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
|
22 |
-
/* @TODO: delete all transient, options and files you may have added
|
23 |
-
delete_transient( 'TRANSIENT_NAME' );
|
24 |
-
delete_option('OPTION_NAME');
|
25 |
-
//info: remove custom file directory for main site
|
26 |
-
$upload_dir = wp_upload_dir();
|
27 |
-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
|
28 |
-
if (is_dir($directory)) {
|
29 |
-
foreach(glob($directory.'*.*') as $v){
|
30 |
-
unlink($v);
|
31 |
-
}
|
32 |
-
rmdir($directory);
|
33 |
-
}
|
34 |
-
*/
|
35 |
-
if ( $blogs ) {
|
36 |
-
|
37 |
-
foreach ( $blogs as $blog ) {
|
38 |
-
switch_to_blog( $blog['blog_id'] );
|
39 |
-
/* @TODO: delete all transient, options and files you may have added
|
40 |
-
delete_transient( 'TRANSIENT_NAME' );
|
41 |
-
delete_option('OPTION_NAME');
|
42 |
-
//info: remove custom file directory for main site
|
43 |
-
$upload_dir = wp_upload_dir();
|
44 |
-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
|
45 |
-
if (is_dir($directory)) {
|
46 |
-
foreach(glob($directory.'*.*') as $v){
|
47 |
-
unlink($v);
|
48 |
-
}
|
49 |
-
rmdir($directory);
|
50 |
-
}
|
51 |
-
//info: remove and optimize tables
|
52 |
-
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
|
53 |
-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
|
54 |
-
*/
|
55 |
-
restore_current_blog();
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
} else {
|
60 |
-
/* @TODO: delete all transient, options and files you may have added
|
61 |
-
delete_transient( 'TRANSIENT_NAME' );
|
62 |
-
delete_option('OPTION_NAME');
|
63 |
-
//info: remove custom file directory for main site
|
64 |
-
$upload_dir = wp_upload_dir();
|
65 |
-
$directory = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . "CUSTOM_DIRECTORY_NAME" . DIRECTORY_SEPARATOR;
|
66 |
-
if (is_dir($directory)) {
|
67 |
-
foreach(glob($directory.'*.*') as $v){
|
68 |
-
unlink($v);
|
69 |
-
}
|
70 |
-
rmdir($directory);
|
71 |
-
}
|
72 |
-
//info: remove and optimize tables
|
73 |
-
$GLOBALS['wpdb']->query("DROP TABLE `".$GLOBALS['wpdb']->prefix."TABLE_NAME`");
|
74 |
-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `" .$GLOBALS['wpdb']->prefix."options`");
|
75 |
-
*/
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|