Version Description
- Integration with members plugin
Download this release
Release Info
| Developer | nmarks |
| Plugin | |
| Version | 1.6.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.6.2 to 1.6.3
- README.txt +4 -1
- admin/class-gravity-forms-event-tracking-addon.php +0 -68
- admin/class-gravity-forms-event-tracking-admin.php +0 -209
- gravity-forms-event-tracking.php +1 -1
- includes/class-gravity-forms-event-tracking-feed.php +9 -1
- includes/class-gravity-forms-event-tracking.php +0 -489
- public/class-gravity-forms-event-tracking.php +0 -288
- public/includes/ga-mp/src/Racecore/GATracking/Autoloader.php +0 -74
- public/includes/ga-mp/src/Racecore/GATracking/Exception.php +0 -22
- public/includes/ga-mp/src/Racecore/GATracking/Exception/EndpointServerException.php +0 -24
- public/includes/ga-mp/src/Racecore/GATracking/Exception/MissingConfigurationException.php +0 -24
- public/includes/ga-mp/src/Racecore/GATracking/Exception/MissingTrackingParameterException.php +0 -24
- public/includes/ga-mp/src/Racecore/GATracking/GATracking.php +0 -477
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/AbstractTracking.php +0 -31
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/App/Event.php +0 -107
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/App/Screen.php +0 -107
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Campaign.php +0 -233
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Item.php +0 -230
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php +0 -209
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Event.php +0 -148
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Exception.php +0 -85
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Page.php +0 -112
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/Social.php +0 -125
- public/includes/ga-mp/src/Racecore/GATracking/Tracking/User/Timing.php +0 -250
README.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: nmarks
|
|
| 3 |
Tags: gravity forms, google analytics, event tracking
|
| 4 |
Requires at least: 3.5.2
|
| 5 |
Tested up to: 4.1
|
| 6 |
-
Stable tag: 1.6.
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
|
@@ -83,6 +83,9 @@ Check out the documentation on [github](https://github.com/nathanmarks/wordpress
|
|
| 83 |
|
| 84 |
== Changelog ==
|
| 85 |
|
|
|
|
|
|
|
|
|
|
| 86 |
= 1.6.2 =
|
| 87 |
* Fixed bug where manual event values were not sent properly.
|
| 88 |
|
| 3 |
Tags: gravity forms, google analytics, event tracking
|
| 4 |
Requires at least: 3.5.2
|
| 5 |
Tested up to: 4.1
|
| 6 |
+
Stable tag: 1.6.3
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
| 83 |
|
| 84 |
== Changelog ==
|
| 85 |
|
| 86 |
+
= 1.6.3 =
|
| 87 |
+
* Integration with members plugin
|
| 88 |
+
|
| 89 |
= 1.6.2 =
|
| 90 |
* Fixed bug where manual event values were not sent properly.
|
| 91 |
|
admin/class-gravity-forms-event-tracking-addon.php
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Gravity forms event tracking
|
| 4 |
-
*
|
| 5 |
-
* @package Gravity_Forms_Event_Tracking_Admin
|
| 6 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 7 |
-
* @author Ronald Huereca <ronalfy@gmail.com>
|
| 8 |
-
* @license GPL-2.0+
|
| 9 |
-
* @link http://www.nvisionsolutions.ca
|
| 10 |
-
* @copyright 2014 Nathan Marks
|
| 11 |
-
*/
|
| 12 |
-
|
| 13 |
-
/**
|
| 14 |
-
*
|
| 15 |
-
* @package Gravity_Forms_Event_Tracking_Addon
|
| 16 |
-
* @author Ronald Huereca <ronalfy@gmail.com>
|
| 17 |
-
*/
|
| 18 |
-
if ( class_exists( "GFForms" ) ) {
|
| 19 |
-
|
| 20 |
-
GFForms::include_addon_framework();
|
| 21 |
-
|
| 22 |
-
class Gravity_Forms_Event_Tracking_Addon extends GFAddOn {
|
| 23 |
-
protected $_version = "1.0";
|
| 24 |
-
protected $_min_gravityforms_version = "1.7.9";
|
| 25 |
-
protected $_slug = "gravity-forms-event-tracking";
|
| 26 |
-
protected $_path = "gravity-forms-google-analytics-event-tracking/gravity-forms-event-tracking.php";
|
| 27 |
-
protected $_full_path = __FILE__;
|
| 28 |
-
protected $_url = "https://wordpress.org/plugins/gravity-forms-google-analytics-event-tracking";
|
| 29 |
-
protected $_title = "Gravity Forms Google Analytics Event Tracking";
|
| 30 |
-
protected $_short_title = "Event Tracking";
|
| 31 |
-
|
| 32 |
-
// ------- Plugin settings -------
|
| 33 |
-
|
| 34 |
-
public function plugin_settings_fields() {
|
| 35 |
-
return array(
|
| 36 |
-
array(
|
| 37 |
-
'title' => __( 'Google Analytics', 'gravity-forms-google-analytics-event-tracking' ),
|
| 38 |
-
'description' => __( 'Enter your UA code (UA-XXXX-Y) here.', 'gravity-forms-google-analytics-event-tracking' ),
|
| 39 |
-
'fields' => array(
|
| 40 |
-
array(
|
| 41 |
-
'name' => 'gravity_forms_event_tracking_ua',
|
| 42 |
-
'label' => __( 'UA Tracking ID', 'gravity-forms-google-analytics-event-tracking' ),
|
| 43 |
-
'type' => 'text',
|
| 44 |
-
'class' => 'medium',
|
| 45 |
-
'tooltip' => 'UA-XXXX-Y',
|
| 46 |
-
'feedback_callback' => array( $this, 'ua_validation' )
|
| 47 |
-
),
|
| 48 |
-
)
|
| 49 |
-
),
|
| 50 |
-
);
|
| 51 |
-
}
|
| 52 |
-
/**
|
| 53 |
-
* Basic Validation
|
| 54 |
-
*/
|
| 55 |
-
public function ua_validation($input ) {
|
| 56 |
-
$input = strip_tags( stripslashes( $input ) );
|
| 57 |
-
$ua_regex = "/^UA-[0-9]{5,}-[0-9]{1,}$/";
|
| 58 |
-
if (preg_match($ua_regex, $input)) {
|
| 59 |
-
return true;
|
| 60 |
-
} else {
|
| 61 |
-
$this->log_error( __( 'Invalid UA ID', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 62 |
-
return false;
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
new Gravity_Forms_Event_Tracking_Addon();
|
| 68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-gravity-forms-event-tracking-admin.php
DELETED
|
@@ -1,209 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Gravity forms event tracking
|
| 4 |
-
*
|
| 5 |
-
* @package Gravity_Forms_Event_Tracking_Admin
|
| 6 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 7 |
-
* @license GPL-2.0+
|
| 8 |
-
* @link http://www.nvisionsolutions.ca
|
| 9 |
-
* @copyright 2014 Nathan Marks
|
| 10 |
-
*/
|
| 11 |
-
|
| 12 |
-
/**
|
| 13 |
-
*
|
| 14 |
-
* @package Gravity_Forms_Event_Tracking_Admin
|
| 15 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 16 |
-
*/
|
| 17 |
-
class Gravity_Forms_Event_Tracking_Admin {
|
| 18 |
-
|
| 19 |
-
/**
|
| 20 |
-
* Instance of this class.
|
| 21 |
-
*
|
| 22 |
-
* @since 1.0.0
|
| 23 |
-
*
|
| 24 |
-
* @var object
|
| 25 |
-
*/
|
| 26 |
-
protected static $instance = null;
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Slug of the plugin screen.
|
| 30 |
-
*
|
| 31 |
-
* @since 1.0.0
|
| 32 |
-
*
|
| 33 |
-
* @var string
|
| 34 |
-
*/
|
| 35 |
-
protected $plugin_screen_hook_suffix = null;
|
| 36 |
-
|
| 37 |
-
/**
|
| 38 |
-
* Initialize the plugin by loading admin scripts & styles and adding a
|
| 39 |
-
* settings page and menu.
|
| 40 |
-
*
|
| 41 |
-
* @since 1.0.0
|
| 42 |
-
*/
|
| 43 |
-
private function __construct() {
|
| 44 |
-
|
| 45 |
-
$plugin = Gravity_Forms_Event_Tracking::get_instance();
|
| 46 |
-
$this->plugin_slug = $plugin->get_plugin_slug();
|
| 47 |
-
|
| 48 |
-
// Add an action link pointing to the options page.
|
| 49 |
-
$plugin_basename = plugin_basename( plugin_dir_path( realpath( dirname( __FILE__ ) ) ) . $this->plugin_slug . '.php' );
|
| 50 |
-
|
| 51 |
-
add_filter( 'plugin_action_links_' . $plugin_basename, array( $this, 'add_action_links' ) );
|
| 52 |
-
|
| 53 |
-
//Add items to Gravity Forms settings
|
| 54 |
-
add_filter( 'gform_form_settings', array( $this, 'form_settings' ), 10, 2 );
|
| 55 |
-
add_filter( 'gform_tooltips', array( $this, 'add_gforms_tooltips' ) );
|
| 56 |
-
add_filter( 'gform_pre_form_settings_save', array( $this, 'save_gforms_data' ), 10, 1 );
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
/**
|
| 60 |
-
* Save Gravity Forms Data
|
| 61 |
-
*
|
| 62 |
-
* @since 1.0.0
|
| 63 |
-
*
|
| 64 |
-
* @return array sanitized gravity form settings
|
| 65 |
-
*/
|
| 66 |
-
public function save_gforms_data( $form_data ) {
|
| 67 |
-
|
| 68 |
-
$form_data[ 'gaEventCategory' ] = rgpost( 'ga_event_category' );
|
| 69 |
-
$form_data[ 'gaEventLabel' ] = rgpost( 'ga_event_label' );
|
| 70 |
-
$form_data[ 'gaEventAction' ] = rgpost( 'ga_event_action' );
|
| 71 |
-
$form_data[ 'gaEventValue' ] = rgpost( 'ga_event_value' );
|
| 72 |
-
|
| 73 |
-
return $form_data;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
/**
|
| 78 |
-
* Add Gravity Forms Tooltips
|
| 79 |
-
*
|
| 80 |
-
* @since 1.0.0
|
| 81 |
-
*
|
| 82 |
-
* @return array Gravity Form tooltips
|
| 83 |
-
*/
|
| 84 |
-
public function add_gforms_tooltips( $tooltips ) {
|
| 85 |
-
$tooltips[ 'ga_event_category' ] = sprintf( '<h6>%s</h6>%s', __( 'Event Category', 'gravity-forms-google-analytics-event-tracking' ), __( 'Enter your Google Analytics goal event category', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 86 |
-
$tooltips[ 'ga_event_label' ] = sprintf( '<h6>%s</h6>%s', __( 'Event Label', 'gravity-forms-google-analytics-event-tracking' ), __( 'Enter your Google Analytics goal event label', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 87 |
-
$tooltips[ 'ga_event_action' ] = sprintf( '<h6>%s</h6>%s', __( 'Event Action', 'gravity-forms-google-analytics-event-tracking' ), __( 'Enter your Google Analytics goal event action', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 88 |
-
$tooltips[ 'ga_event_value' ] = sprintf( '<h6>%s</h6>%s', __( 'Event Value', 'gravity-forms-google-analytics-event-tracking' ), __( 'Enter your Google Analytics goal event value. Leave blank to omit pushing a value to Google Analytics.', 'gravity-forms-google-analytics-event-tracking' ) );
|
| 89 |
-
return $tooltips;
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
/**
|
| 93 |
-
* Add settings to the form settings page
|
| 94 |
-
*
|
| 95 |
-
* @since 1.0.0
|
| 96 |
-
*
|
| 97 |
-
* @return array Gravity Form settings
|
| 98 |
-
*/
|
| 99 |
-
public function form_settings( $form_settings, $form ) {
|
| 100 |
-
$event_category = '
|
| 101 |
-
<tr>
|
| 102 |
-
<th>
|
| 103 |
-
<label for="ga_event_category" style="display:block;">' .
|
| 104 |
-
__("Event Category", "gravity-forms-google-analytics-event-tracking") . ' ' .
|
| 105 |
-
gform_tooltip("ga_event_category", "", true) .
|
| 106 |
-
'</label>
|
| 107 |
-
</th>
|
| 108 |
-
<td>
|
| 109 |
-
<input type="text" id="ga_event_category" name="ga_event_category" class="fieldwidth-3" value="' . esc_attr(rgar($form, 'gaEventCategory')) . '" />
|
| 110 |
-
</td>
|
| 111 |
-
</tr>';
|
| 112 |
-
$event_label = '
|
| 113 |
-
<tr>
|
| 114 |
-
<th>
|
| 115 |
-
<label for="ga_event_label" style="display:block;">' .
|
| 116 |
-
__("Event Label", "gravity-forms-google-analytics-event-tracking") . ' ' .
|
| 117 |
-
gform_tooltip("ga_event_label", "", true) .
|
| 118 |
-
'</label>
|
| 119 |
-
</th>
|
| 120 |
-
<td>
|
| 121 |
-
<input type="text" id="ga_event_label" name="ga_event_label" class="fieldwidth-3" value="' . esc_attr(rgar($form, 'gaEventLabel')) . '" />
|
| 122 |
-
</td>
|
| 123 |
-
</tr>';
|
| 124 |
-
$event_action = '
|
| 125 |
-
<tr>
|
| 126 |
-
<th>
|
| 127 |
-
<label for="ga_event_action" style="display:block;">' .
|
| 128 |
-
__("Event Action", "gravity-forms-google-analytics-event-tracking") . ' ' .
|
| 129 |
-
gform_tooltip("ga_event_action", "", true) .
|
| 130 |
-
'</label>
|
| 131 |
-
</th>
|
| 132 |
-
<td>
|
| 133 |
-
<input type="text" id="ga_event_action" name="ga_event_action" class="fieldwidth-3" value="' . esc_attr(rgar($form, 'gaEventAction')) . '" />
|
| 134 |
-
</td>
|
| 135 |
-
</tr>';
|
| 136 |
-
$event_value = '
|
| 137 |
-
<tr>
|
| 138 |
-
<th>
|
| 139 |
-
<label for="ga_event_value" style="display:block;">' .
|
| 140 |
-
__("Event Value", "gravity-forms-google-analytics-event-tracking") . ' ' .
|
| 141 |
-
gform_tooltip("ga_event_value", "", true) .
|
| 142 |
-
'</label>
|
| 143 |
-
</th>
|
| 144 |
-
<td>
|
| 145 |
-
<input type="number" id="ga_event_value" name="ga_event_value" class="fieldwidth-3" value="' . esc_attr(rgar($form, 'gaEventValue')) . '" />
|
| 146 |
-
<p><strong>Notice:</strong> You can leave this field blank to use the payment amount on forms taking payment.</p>
|
| 147 |
-
</td>
|
| 148 |
-
</tr>';
|
| 149 |
-
$event_instructions = '
|
| 150 |
-
<tr>
|
| 151 |
-
<th></th>
|
| 152 |
-
<td>
|
| 153 |
-
<p>If you leave these <strong>blank</strong>, the following defaults will be used when the event is tracked:</p>
|
| 154 |
-
<p>
|
| 155 |
-
<strong>'.__("Event Category", "gravity-forms-google-analytics-event-tracking").':</strong> Forms<br>
|
| 156 |
-
<strong>'.__("Event Action", "gravity-forms-google-analytics-event-tracking").':</strong> Submission<br>
|
| 157 |
-
<strong>'.__("Event Label", "gravity-forms-google-analytics-event-tracking").':</strong> Form: Form Name ID: X
|
| 158 |
-
</p>
|
| 159 |
-
</td>
|
| 160 |
-
</tr>';
|
| 161 |
-
$event_settings = array(
|
| 162 |
-
'instructions' => $event_instructions,
|
| 163 |
-
'cat' => $event_category,
|
| 164 |
-
'action' => $event_action,
|
| 165 |
-
'label' => $event_label,
|
| 166 |
-
'value' => $event_value,
|
| 167 |
-
);
|
| 168 |
-
$event_tracking = array( __( 'Event Tracking', 'gravity-forms-google-analytics-event-tracking' ) => $event_settings );
|
| 169 |
-
$form_settings = $form_settings + $event_tracking;
|
| 170 |
-
return $form_settings;
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
/**
|
| 174 |
-
* Return an instance of this class.
|
| 175 |
-
*
|
| 176 |
-
* @since 1.0.0
|
| 177 |
-
*
|
| 178 |
-
* @return object A single instance of this class.
|
| 179 |
-
*/
|
| 180 |
-
public static function get_instance() {
|
| 181 |
-
|
| 182 |
-
// If the single instance hasn't been set, set it now.
|
| 183 |
-
if ( null == self::$instance ) {
|
| 184 |
-
self::$instance = new self;
|
| 185 |
-
}
|
| 186 |
-
|
| 187 |
-
return self::$instance;
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
/**
|
| 191 |
-
* Add settings action link to the plugins page.
|
| 192 |
-
*
|
| 193 |
-
* @since 1.0.0
|
| 194 |
-
*/
|
| 195 |
-
public function add_action_links( $links ) {
|
| 196 |
-
|
| 197 |
-
return array_merge(
|
| 198 |
-
array(
|
| 199 |
-
'settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=gf_settings&subview=gravity-forms-event-tracking' ) ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>'
|
| 200 |
-
),
|
| 201 |
-
$links
|
| 202 |
-
);
|
| 203 |
-
|
| 204 |
-
}
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gravity-forms-event-tracking.php
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 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: 1.6.
|
| 14 |
* Author: Nathan Marks
|
| 15 |
* Author URI: http://www.nvisionsolutions.ca
|
| 16 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
| 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: 1.6.3
|
| 14 |
* Author: Nathan Marks
|
| 15 |
* Author URI: http://www.nvisionsolutions.ca
|
| 16 |
* Text Domain: gravity-forms-google-analytics-event-tracking
|
includes/class-gravity-forms-event-tracking-feed.php
CHANGED
|
@@ -14,7 +14,7 @@ GFForms::include_feed_addon_framework();
|
|
| 14 |
|
| 15 |
class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
| 16 |
|
| 17 |
-
protected $_version = "1.6.
|
| 18 |
protected $_min_gravityforms_version = "1.8.20";
|
| 19 |
|
| 20 |
/**
|
|
@@ -32,6 +32,14 @@ class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
|
| 32 |
protected $_title = "Gravity Forms Google Analytics Event Tracking";
|
| 33 |
protected $_short_title = "Event Tracking";
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
public $ua_id = false;
|
| 36 |
|
| 37 |
private static $_instance = null;
|
| 14 |
|
| 15 |
class Gravity_Forms_Event_Tracking extends GFFeedAddOn {
|
| 16 |
|
| 17 |
+
protected $_version = "1.6.3";
|
| 18 |
protected $_min_gravityforms_version = "1.8.20";
|
| 19 |
|
| 20 |
/**
|
| 32 |
protected $_title = "Gravity Forms Google Analytics Event Tracking";
|
| 33 |
protected $_short_title = "Event Tracking";
|
| 34 |
|
| 35 |
+
// Members plugin integration
|
| 36 |
+
protected $_capabilities = array( 'gravityforms_event_tracking', 'gravityforms_event_tracking_uninstall' );
|
| 37 |
+
|
| 38 |
+
// Permissions
|
| 39 |
+
protected $_capabilities_settings_page = 'gravityforms_event_tracking';
|
| 40 |
+
protected $_capabilities_form_settings = 'gravityforms_event_tracking';
|
| 41 |
+
protected $_capabilities_uninstall = 'gravityforms_event_tracking_uninstall';
|
| 42 |
+
|
| 43 |
public $ua_id = false;
|
| 44 |
|
| 45 |
private static $_instance = null;
|
includes/class-gravity-forms-event-tracking.php
DELETED
|
@@ -1,489 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Gravity forms event tracking
|
| 4 |
-
*
|
| 5 |
-
* @package Gravity_Forms_Event_Tracking
|
| 6 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 7 |
-
* @license GPL-2.0+
|
| 8 |
-
* @link http://www.nvisionsolutions.ca
|
| 9 |
-
* @copyright 2014 Nathan Marks
|
| 10 |
-
*/
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
GFForms::include_addon_framework();
|
| 14 |
-
|
| 15 |
-
class Gravity_Forms_Event_Tracking extends GFAddOn {
|
| 16 |
-
protected $_version = "1.5.5";
|
| 17 |
-
protected $_min_gravityforms_version = "1.8.20";
|
| 18 |
-
|
| 19 |
-
/**
|
| 20 |
-
* The actual slug of this plugin is too long for GF settings to save properly.
|
| 21 |
-
* With the appended/prepended string it attempts to insert an option over
|
| 22 |
-
* 64 chars in length.
|
| 23 |
-
*
|
| 24 |
-
* @TODO Resolve this in 2.0 somehow...
|
| 25 |
-
*/
|
| 26 |
-
protected $_slug = "gravity-forms-event-tracking";
|
| 27 |
-
protected $_text_domain = "gravity-forms-google-analytics-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 = "Event Tracking";
|
| 33 |
-
|
| 34 |
-
public $ua_id = false;
|
| 35 |
-
|
| 36 |
-
private static $_instance = null;
|
| 37 |
-
|
| 38 |
-
public static function get_instance() {
|
| 39 |
-
if ( self::$_instance == null ) {
|
| 40 |
-
self::$_instance = new Gravity_Forms_Event_Tracking();
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
return self::$_instance;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
/**
|
| 48 |
-
* Overriding init function to change the load_plugin_textdomain call.
|
| 49 |
-
* See comment above for explanation.
|
| 50 |
-
*/
|
| 51 |
-
public function init() {
|
| 52 |
-
|
| 53 |
-
load_plugin_textdomain( $this->_text_domain, false, $this->_text_domain . '/languages' );
|
| 54 |
-
|
| 55 |
-
add_filter( 'gform_logging_supported', array( $this, 'set_logging_supported' ) );
|
| 56 |
-
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_action_links' ) );
|
| 57 |
-
|
| 58 |
-
if ( RG_CURRENT_PAGE == 'admin-ajax.php' ) {
|
| 59 |
-
|
| 60 |
-
//If gravity forms is supported, initialize AJAX
|
| 61 |
-
if ( $this->is_gravityforms_supported() ) {
|
| 62 |
-
$this->init_ajax();
|
| 63 |
-
}
|
| 64 |
-
} else if ( is_admin() ) {
|
| 65 |
-
|
| 66 |
-
$this->init_admin();
|
| 67 |
-
|
| 68 |
-
} else {
|
| 69 |
-
|
| 70 |
-
if ( $this->is_gravityforms_supported() ) {
|
| 71 |
-
$this->init_frontend();
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
/**
|
| 79 |
-
* Public facing init
|
| 80 |
-
*
|
| 81 |
-
* @since 1.5.0
|
| 82 |
-
*/
|
| 83 |
-
public function init_frontend() {
|
| 84 |
-
|
| 85 |
-
$this->setup();
|
| 86 |
-
|
| 87 |
-
add_filter( 'gform_preview_styles', array( $this, 'enqueue_preview_styles' ), 10, 2 );
|
| 88 |
-
add_filter( 'gform_print_styles', array( $this, 'enqueue_print_styles' ), 10, 2 );
|
| 89 |
-
add_action( 'gform_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 2 );
|
| 90 |
-
|
| 91 |
-
if ( $this->load_ua_settings() ) {
|
| 92 |
-
$this->load_measurement_client();
|
| 93 |
-
|
| 94 |
-
// Tracking hooks
|
| 95 |
-
add_action( 'gform_after_submission', array( $this, 'track_form_after_submission' ), 10, 2 );
|
| 96 |
-
|
| 97 |
-
// IPN hook for paypal standard!
|
| 98 |
-
if ( class_exists( 'GFPayPal' ) ) {
|
| 99 |
-
add_action( 'gform_paypal_post_ipn', array( $this, 'paypal_track_form_post_ipn' ), 10, 2 );
|
| 100 |
-
}
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
/**
|
| 106 |
-
* Load UA Settings
|
| 107 |
-
*
|
| 108 |
-
* @since 1.4.0
|
| 109 |
-
* @return bool Returns true if UA ID is loaded, false otherwise
|
| 110 |
-
*/
|
| 111 |
-
private function load_ua_settings() {
|
| 112 |
-
$gravity_forms_add_on_settings = get_option( 'gravityformsaddon_gravity-forms-event-tracking_settings', array() );
|
| 113 |
-
|
| 114 |
-
$this->ua_id = $ua_id = false;
|
| 115 |
-
|
| 116 |
-
$ua_id = $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua' ];
|
| 117 |
-
|
| 118 |
-
$ua_regex = "/^UA-[0-9]{5,}-[0-9]{1,}$/";
|
| 119 |
-
|
| 120 |
-
if ( preg_match( $ua_regex, $ua_id ) ) {
|
| 121 |
-
$this->ua_id = $ua_id;
|
| 122 |
-
return true;
|
| 123 |
-
}
|
| 124 |
-
|
| 125 |
-
if ( ! $this->ua_id )
|
| 126 |
-
return false;
|
| 127 |
-
}
|
| 128 |
-
|
| 129 |
-
/**
|
| 130 |
-
* Load the google measurement protocol PHP client.
|
| 131 |
-
*
|
| 132 |
-
* @since 1.4.0
|
| 133 |
-
*/
|
| 134 |
-
private function load_measurement_client() {
|
| 135 |
-
require_once( 'vendor/ga-mp/src/Racecore/GATracking/Autoloader.php');
|
| 136 |
-
Racecore\GATracking\Autoloader::register( dirname(__FILE__) . '/vendor/ga-mp/src/' );
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
/**
|
| 140 |
-
* Handle the form after submission before sending to the event push
|
| 141 |
-
*
|
| 142 |
-
* @since 1.4.0
|
| 143 |
-
* @param array $entry Gravity Forms entry object
|
| 144 |
-
* @param array $form Gravity Forms form object
|
| 145 |
-
*/
|
| 146 |
-
public function track_form_after_submission( $entry, $form ) {
|
| 147 |
-
global $post;
|
| 148 |
-
// Temporary until Gravity fix a bug
|
| 149 |
-
// $entry = GFAPI::get_entry( $entry['id'] );
|
| 150 |
-
|
| 151 |
-
// Set some vars to send to GA
|
| 152 |
-
$ga_cookie = $_COOKIE['_ga'];
|
| 153 |
-
$document_location = 'http' . ( isset( $_SERVER['HTTPS'] ) ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'];
|
| 154 |
-
$document_title = get_the_title( $post );
|
| 155 |
-
|
| 156 |
-
$ga_event_vars = array(
|
| 157 |
-
'ga_cookie' => $_COOKIE['_ga'],
|
| 158 |
-
'document_location' => $document_location,
|
| 159 |
-
'document_title' => $document_title
|
| 160 |
-
);
|
| 161 |
-
|
| 162 |
-
gform_update_meta( $entry['id'], 'ga_event_vars', maybe_serialize( $ga_event_vars ) );
|
| 163 |
-
|
| 164 |
-
if ( isset($entry['payment_status']) && $entry['payment_status'] == "Processing" ) {
|
| 165 |
-
return;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
// Push the event to google
|
| 169 |
-
$this->push_event( $entry, $form );
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
/**
|
| 173 |
-
* Handle the IPN response for pushing the event
|
| 174 |
-
*
|
| 175 |
-
* @since 1.4.0
|
| 176 |
-
* @param array $post_object global post array from the IPN
|
| 177 |
-
* @param array $entry Gravity Forms entry object
|
| 178 |
-
*/
|
| 179 |
-
public function paypal_track_form_post_ipn( $post_object, $entry ) {
|
| 180 |
-
// Check if the payment was completed before continuing
|
| 181 |
-
if ( strtolower( $entry['payment_status'] ) != 'paid' ) {
|
| 182 |
-
return;
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
$form = GFFormsModel::get_form_meta( $entry['form_id'] );
|
| 186 |
-
|
| 187 |
-
// Push the event to google
|
| 188 |
-
$this->push_event( $entry, $form );
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
/**
|
| 192 |
-
* Push the Google Analytics Event!
|
| 193 |
-
*
|
| 194 |
-
* @since 1.4.0
|
| 195 |
-
* @param array $event Gravity Forms event object
|
| 196 |
-
* @param array $form Gravity Forms form object
|
| 197 |
-
*/
|
| 198 |
-
private function push_event( $entry, $form ) {
|
| 199 |
-
if ( isset( $form['gravity-forms-event-tracking'] ) && $is_disabled = rgar( $form['gravity-forms-event-tracking'], 'gaEventTrackingDisabled' ) ) {
|
| 200 |
-
return false;
|
| 201 |
-
}
|
| 202 |
-
|
| 203 |
-
// Init tracking object
|
| 204 |
-
$this->tracking = new \Racecore\GATracking\GATracking( apply_filters( 'gform_ua_id', $this->ua_id, $form ), true );
|
| 205 |
-
$event = new \Racecore\GATracking\Tracking\Event();
|
| 206 |
-
|
| 207 |
-
// get some stored vars
|
| 208 |
-
$ga_event_vars = maybe_unserialize( gform_get_meta( $entry['id'], 'ga_event_vars' ) );
|
| 209 |
-
|
| 210 |
-
// Set some defaults
|
| 211 |
-
$event->setDocumentLocation( $ga_event_vars['document_location'] );
|
| 212 |
-
$event->setDocumentTitle( $ga_event_vars['document_title'] );
|
| 213 |
-
|
| 214 |
-
// Override this in case coming from paypal IPN
|
| 215 |
-
$_COOKIE['_ga'] = $ga_event_vars['ga_cookie'];
|
| 216 |
-
|
| 217 |
-
// Get event defaults
|
| 218 |
-
$event_category = 'Forms';
|
| 219 |
-
$event_label = sprintf( "Form: %s ID: %s", $form['title'], $form['id'] );
|
| 220 |
-
$event_action = 'Submission';
|
| 221 |
-
|
| 222 |
-
// IF this form has payment, we should use that for the value
|
| 223 |
-
// as long a custom value hasn't been set
|
| 224 |
-
$event_value = $this->get_event_value( $entry, $form );
|
| 225 |
-
|
| 226 |
-
// Overwrite with Gravity Form Settings if necessary
|
| 227 |
-
if ( function_exists( 'rgar' ) && isset( $form['gravity-forms-event-tracking'] ) ) {
|
| 228 |
-
// Event category
|
| 229 |
-
$gf_event_category = rgar( $form['gravity-forms-event-tracking'], 'gaEventCategory' );
|
| 230 |
-
if ( !empty( $gf_event_category ) ) {
|
| 231 |
-
$event_category = GFCommon::replace_variables( $gf_event_category, $form, $entry, false, false, true, 'text' );
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
// Event label
|
| 235 |
-
$gf_event_label = rgar( $form['gravity-forms-event-tracking'], 'gaEventLabel' );
|
| 236 |
-
if ( !empty( $gf_event_label ) ) {
|
| 237 |
-
$event_label = GFCommon::replace_variables( $gf_event_label, $form, $entry, false, false, true, 'text' );
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
-
// Event action
|
| 241 |
-
$gf_event_action = rgar( $form['gravity-forms-event-tracking'], 'gaEventAction' );
|
| 242 |
-
if ( !empty( $gf_event_action ) ) {
|
| 243 |
-
$event_action = GFCommon::replace_variables( $gf_event_action, $form, $entry, false, false, true, 'text' );
|
| 244 |
-
}
|
| 245 |
-
|
| 246 |
-
// Event value
|
| 247 |
-
$gf_event_value = rgar( $form['gravity-forms-event-tracking'], 'gaEventValue' );
|
| 248 |
-
if ( !empty( $gf_event_value ) ) {
|
| 249 |
-
$event_value = GFCommon::replace_variables( $gf_event_value, $form, $entry, false, false, true, 'text' );
|
| 250 |
-
}
|
| 251 |
-
}
|
| 252 |
-
|
| 253 |
-
// Set our event object variables
|
| 254 |
-
$event->setEventCategory( apply_filters( 'gform_event_category', $event_category, $form ) );
|
| 255 |
-
$event->setEventAction( apply_filters( 'gform_event_action', $event_action, $form ) );
|
| 256 |
-
$event->setEventLabel( apply_filters( 'gform_event_label', $event_label, $form ) );
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
if ( $event_value = apply_filters( 'gform_event_value', $event_value, $form ) ) {
|
| 260 |
-
// Event value must be a valid float!
|
| 261 |
-
$event_value = (float) $event_value;
|
| 262 |
-
$event->setEventValue( $event_value );
|
| 263 |
-
}
|
| 264 |
-
|
| 265 |
-
// Pppp Push it!
|
| 266 |
-
$this->tracking->addTracking( $event );
|
| 267 |
-
|
| 268 |
-
try {
|
| 269 |
-
$this->tracking->send();
|
| 270 |
-
} catch (Exception $e) {
|
| 271 |
-
error_log( $e->getMessage() . ' in ' . get_class( $e ) );
|
| 272 |
-
}
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
/**
|
| 276 |
-
* Get the event value for payment entries
|
| 277 |
-
*
|
| 278 |
-
* @since 1.4.0
|
| 279 |
-
* @param array $event Gravity Forms event object
|
| 280 |
-
* @return string/boolean Event value or false if not a payment form
|
| 281 |
-
*/
|
| 282 |
-
private function get_event_value( $entry ) {
|
| 283 |
-
$value = rgar( $entry, 'payment_amount' );
|
| 284 |
-
|
| 285 |
-
if ( ! empty( $value ) && intval( $value ) ) {
|
| 286 |
-
return intval( $value );
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
return false;
|
| 290 |
-
}
|
| 291 |
-
|
| 292 |
-
/**
|
| 293 |
-
* Plugin settings fields
|
| 294 |
-
*
|
| 295 |
-
* @return array Array of plugin settings
|
| 296 |
-
*/
|
| 297 |
-
public function plugin_settings_fields() {
|
| 298 |
-
return array(
|
| 299 |
-
array(
|
| 300 |
-
'title' => __( 'Google Analytics', $this->_text_domain ),
|
| 301 |
-
'description' => __( 'Enter your UA code (UA-XXXX-Y) here.', $this->_text_domain ),
|
| 302 |
-
'fields' => array(
|
| 303 |
-
array(
|
| 304 |
-
'name' => 'gravity_forms_event_tracking_ua',
|
| 305 |
-
'label' => __( 'UA Tracking ID', $this->_text_domain ),
|
| 306 |
-
'type' => 'text',
|
| 307 |
-
'class' => 'medium',
|
| 308 |
-
'tooltip' => 'UA-XXXX-Y',
|
| 309 |
-
'feedback_callback' => array( $this, 'ua_validation' )
|
| 310 |
-
),
|
| 311 |
-
)
|
| 312 |
-
),
|
| 313 |
-
);
|
| 314 |
-
}
|
| 315 |
-
|
| 316 |
-
/**
|
| 317 |
-
* Form settings page title
|
| 318 |
-
*
|
| 319 |
-
* @since 1.5.0
|
| 320 |
-
* @return string Form Settings Title
|
| 321 |
-
*/
|
| 322 |
-
public function form_settings_page_title() {
|
| 323 |
-
return __( 'Event Tracking', $this->_text_domain );
|
| 324 |
-
}
|
| 325 |
-
|
| 326 |
-
/**
|
| 327 |
-
* Form settings icon
|
| 328 |
-
*
|
| 329 |
-
* @since 1.5.0
|
| 330 |
-
* @return string HTML Markup for icon
|
| 331 |
-
*/
|
| 332 |
-
public function form_settings_icon() {
|
| 333 |
-
return '<i class="fa fa-crosshairs"></i>';
|
| 334 |
-
}
|
| 335 |
-
|
| 336 |
-
/**
|
| 337 |
-
* Form settings fields
|
| 338 |
-
*
|
| 339 |
-
* @since 1.5.0
|
| 340 |
-
* @return array Array of form settings
|
| 341 |
-
*/
|
| 342 |
-
public function form_settings_fields( $form ) {
|
| 343 |
-
return array(
|
| 344 |
-
array(
|
| 345 |
-
"title" => __( 'Event Tracking Settings', $this->_text_domain ),
|
| 346 |
-
"fields" => array(
|
| 347 |
-
array(
|
| 348 |
-
"label" => "",
|
| 349 |
-
"type" => "instruction_field",
|
| 350 |
-
"name" => "instructions"
|
| 351 |
-
),
|
| 352 |
-
array(
|
| 353 |
-
"label" => __( 'Event Category', $this->_text_domain ),
|
| 354 |
-
"type" => "text",
|
| 355 |
-
"name" => "gaEventCategory",
|
| 356 |
-
"class" => "medium merge-tag-support mt-position-right",
|
| 357 |
-
"tooltip" => sprintf( '<h6>%s</h6>%s', __( 'Event Category', $this->_text_domain ), __( 'Enter your Google Analytics event category', $this->_text_domain ) ),
|
| 358 |
-
),
|
| 359 |
-
array(
|
| 360 |
-
"label" => __( 'Event Action', $this->_text_domain ),
|
| 361 |
-
"type" => "text",
|
| 362 |
-
"name" => "gaEventAction",
|
| 363 |
-
"class" => "medium merge-tag-support mt-position-right",
|
| 364 |
-
"tooltip" => sprintf( '<h6>%s</h6>%s', __( 'Event Action', $this->_text_domain ), __( 'Enter your Google Analytics event action', $this->_text_domain ) ),
|
| 365 |
-
),
|
| 366 |
-
array(
|
| 367 |
-
"label" => __( 'Event Label', $this->_text_domain ),
|
| 368 |
-
"type" => "text",
|
| 369 |
-
"name" => "gaEventLabel",
|
| 370 |
-
"class" => "medium merge-tag-support mt-position-right",
|
| 371 |
-
"tooltip" => sprintf( '<h6>%s</h6>%s', __( 'Event Label', $this->_text_domain ), __( 'Enter your Google Analytics event label', $this->_text_domain ) ),
|
| 372 |
-
),
|
| 373 |
-
array(
|
| 374 |
-
"label" => __( 'Event Value', $this->_text_domain ),
|
| 375 |
-
"type" => "text",
|
| 376 |
-
"name" => "gaEventValue",
|
| 377 |
-
"class" => "medium merge-tag-support mt-position-right",
|
| 378 |
-
"tooltip" => sprintf( '<h6>%s</h6>%s', __( 'Event Value', $this->_text_domain ), __( 'Enter your Google Analytics event value. Leave blank to omit pushing a value to Google Analytics. Or to use the purchase value of a payment based form. <strong>Note:</strong> This must be a number (int/float).', $this->_text_domain ) ),
|
| 379 |
-
),
|
| 380 |
-
)
|
| 381 |
-
),
|
| 382 |
-
array(
|
| 383 |
-
"title" => __( 'Other Settings', $this->_text_domain ),
|
| 384 |
-
"fields" => array(
|
| 385 |
-
array(
|
| 386 |
-
"label" => __( 'Disable Event Tracking', $this->_text_domain ),
|
| 387 |
-
"type" => "checkbox",
|
| 388 |
-
"name" => "gaDisableEventTracking",
|
| 389 |
-
"tooltip" => sprintf( '<h6>%s</h6>%s', __( 'Disable Event Tracking', $this->_text_domain ), __( 'Check this if you don\'t want this form to send any events to Google Analytics.', $this->_text_domain ) ),
|
| 390 |
-
"choices" => array(
|
| 391 |
-
array(
|
| 392 |
-
"label" => "Disabled",
|
| 393 |
-
"name" => "gaEventTrackingDisabled"
|
| 394 |
-
)
|
| 395 |
-
)
|
| 396 |
-
)
|
| 397 |
-
)
|
| 398 |
-
),
|
| 399 |
-
);
|
| 400 |
-
}
|
| 401 |
-
|
| 402 |
-
/**
|
| 403 |
-
* Instruction field
|
| 404 |
-
*
|
| 405 |
-
* @since 1.5.0
|
| 406 |
-
*/
|
| 407 |
-
public function single_setting_row_instruction_field(){
|
| 408 |
-
echo '
|
| 409 |
-
<tr>
|
| 410 |
-
<th colspan="2">
|
| 411 |
-
<p>' . __( "If you leave these blank, the following defaults will be used when the event is tracked", $this->_text_domain ) . ':</p>
|
| 412 |
-
<p>
|
| 413 |
-
<strong>' . __( "Event Category", $this->_text_domain ) . ':</strong> Forms<br>
|
| 414 |
-
<strong>' . __( "Event Action", $this->_text_domain ) . ':</strong> Submission<br>
|
| 415 |
-
<strong>' . __( "Event Label", $this->_text_domain ) . ':</strong> Form: {form_title} ID: {form_id}<br>
|
| 416 |
-
<strong>' . __( "Event Value", $this->_text_domain ) . ':</strong> Payment Amount (on payment forms only, otherwise nothing is sent by default)
|
| 417 |
-
</p>
|
| 418 |
-
</td>
|
| 419 |
-
</tr>';
|
| 420 |
-
}
|
| 421 |
-
|
| 422 |
-
/**
|
| 423 |
-
* Basic Validation
|
| 424 |
-
*
|
| 425 |
-
* @since 1.3.0
|
| 426 |
-
*/
|
| 427 |
-
public function ua_validation($input ) {
|
| 428 |
-
$input = strip_tags( stripslashes( $input ) );
|
| 429 |
-
$ua_regex = "/^UA-[0-9]{5,}-[0-9]{1,}$/";
|
| 430 |
-
if ( preg_match( $ua_regex, $input ) ) {
|
| 431 |
-
return true;
|
| 432 |
-
} else {
|
| 433 |
-
$this->log_error( __( 'Invalid UA Tracking ID', $this->_text_domain ) );
|
| 434 |
-
return false;
|
| 435 |
-
}
|
| 436 |
-
}
|
| 437 |
-
|
| 438 |
-
/**
|
| 439 |
-
* Upgrading functions
|
| 440 |
-
*
|
| 441 |
-
* @since 1.5.0
|
| 442 |
-
*/
|
| 443 |
-
public function upgrade( $previous_version ) {
|
| 444 |
-
|
| 445 |
-
// If the version is below 1.5.0, we need to move the form specific settings
|
| 446 |
-
if ( version_compare( $previous_version, "1.5.0" ) == -1 ) {
|
| 447 |
-
$forms = GFAPI::get_forms( true );
|
| 448 |
-
|
| 449 |
-
foreach ( $forms as $form ) {
|
| 450 |
-
$this->upgrade_old_form_settings( $form );
|
| 451 |
-
}
|
| 452 |
-
}
|
| 453 |
-
|
| 454 |
-
}
|
| 455 |
-
|
| 456 |
-
/**
|
| 457 |
-
* Upgrade old settings created prior to new settings tab
|
| 458 |
-
*
|
| 459 |
-
* @since 1.5.0
|
| 460 |
-
* @param array $form GF Form Object Array
|
| 461 |
-
*/
|
| 462 |
-
public function upgrade_old_form_settings( $form ) {
|
| 463 |
-
$settings = array( 'gaEventCategory', 'gaEventAction', 'gaEventLabel', 'gaEventValue' );
|
| 464 |
-
|
| 465 |
-
foreach( $settings as $key => $setting ) {
|
| 466 |
-
if ( isset( $form[ $setting ] ) && ( ! isset( $form[ $this->_slug ] ) || ! isset( $form[ $this->_slug ][ $setting ] ) || empty( $form[ $this->_slug ][ $setting ] ) ) ) {
|
| 467 |
-
$form[ $this->_slug ][ $setting ] = $form[ $setting ];
|
| 468 |
-
}
|
| 469 |
-
unset( $form[ $setting ] );
|
| 470 |
-
}
|
| 471 |
-
|
| 472 |
-
GFFormsModel::update_form_meta( $form['id'], $form );
|
| 473 |
-
}
|
| 474 |
-
|
| 475 |
-
/**
|
| 476 |
-
* Add settings action link to the plugins page.
|
| 477 |
-
*
|
| 478 |
-
* @since 1.0.0
|
| 479 |
-
*/
|
| 480 |
-
public function add_action_links( $links ) {
|
| 481 |
-
return array_merge(
|
| 482 |
-
array(
|
| 483 |
-
'settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=gf_settings&subview=gravity-forms-event-tracking' ) ) . '">' . __( 'Settings', $this->plugin_slug ) . '</a>'
|
| 484 |
-
),
|
| 485 |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ravity_Forms_Event_Tracking
|
| 4 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 5 |
-
* @license GPL-2.0+
|
| 6 |
-
* @link http://www.nvisionsolutions.ca
|
| 7 |
-
* @copyright 2014 Nathan Marks
|
| 8 |
-
*/
|
| 9 |
-
|
| 10 |
-
/**
|
| 11 |
-
*
|
| 12 |
-
* @package Gravity_Forms_Event_Tracking
|
| 13 |
-
* @author Nathan Marks <nmarks@nvisionsolutions.ca>
|
| 14 |
-
*/
|
| 15 |
-
class Gravity_Forms_Event_Tracking {
|
| 16 |
-
|
| 17 |
-
/**
|
| 18 |
-
* Plugin version, used for cache-busting of style and script file references.
|
| 19 |
-
*
|
| 20 |
-
* @since 1.0.0
|
| 21 |
-
*
|
| 22 |
-
* @var string
|
| 23 |
-
*/
|
| 24 |
-
const VERSION = '1.0.0';
|
| 25 |
-
|
| 26 |
-
/**
|
| 27 |
-
*
|
| 28 |
-
* Unique identifier for your plugin.
|
| 29 |
-
*
|
| 30 |
-
*
|
| 31 |
-
* The variable name is used as the text domain when internationalizing strings
|
| 32 |
-
* of text. Its value should match the Text Domain file header in the main
|
| 33 |
-
* plugin file.
|
| 34 |
-
*
|
| 35 |
-
* @since 1.0.0
|
| 36 |
-
*
|
| 37 |
-
* @var string
|
| 38 |
-
*/
|
| 39 |
-
protected $plugin_slug = 'gravity-forms-google-analytics-event-tracking';
|
| 40 |
-
|
| 41 |
-
/**
|
| 42 |
-
* Instance of this class.
|
| 43 |
-
*
|
| 44 |
-
* @since 1.0.0
|
| 45 |
-
*
|
| 46 |
-
* @var object
|
| 47 |
-
*/
|
| 48 |
-
protected static $instance = null;
|
| 49 |
-
|
| 50 |
-
/**
|
| 51 |
-
* Constructor
|
| 52 |
-
*
|
| 53 |
-
* @since 1.0.0
|
| 54 |
-
*/
|
| 55 |
-
private function __construct() {
|
| 56 |
-
|
| 57 |
-
add_action( 'init', array( $this, 'init' ) );
|
| 58 |
-
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/**
|
| 62 |
-
* Return the plugin slug.
|
| 63 |
-
*
|
| 64 |
-
* @since 1.0.0
|
| 65 |
-
*
|
| 66 |
-
* @return Plugin slug variable.
|
| 67 |
-
*/
|
| 68 |
-
public function get_plugin_slug() {
|
| 69 |
-
return $this->plugin_slug;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
/**
|
| 73 |
-
* Return an instance of this class.
|
| 74 |
-
*
|
| 75 |
-
* @since 1.0.0
|
| 76 |
-
*
|
| 77 |
-
* @return object A single instance of this class.
|
| 78 |
-
*/
|
| 79 |
-
public static function get_instance() {
|
| 80 |
-
|
| 81 |
-
// If the single instance hasn't been set, set it now.
|
| 82 |
-
if ( null == self::$instance ) {
|
| 83 |
-
self::$instance = new self;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
return self::$instance;
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
/**
|
| 90 |
-
* Load the UA settings and add the tracking action if successful
|
| 91 |
-
*
|
| 92 |
-
* @since 1.4.0
|
| 93 |
-
*/
|
| 94 |
-
public function init() {
|
| 95 |
-
|
| 96 |
-
if ( ! is_admin() && $this->load_ua_settings() ) {
|
| 97 |
-
$this->load_measurement_client();
|
| 98 |
-
|
| 99 |
-
// Tracking hooks
|
| 100 |
-
add_action( 'gform_after_submission', array( $this, 'track_form_after_submission' ), 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 );
|
| 105 |
-
}
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/**
|
| 111 |
-
* Load UA Settings
|
| 112 |
-
*
|
| 113 |
-
* @since 1.4.0
|
| 114 |
-
* @return bool Returns true if UA ID is loaded, false otherwise
|
| 115 |
-
*/
|
| 116 |
-
private function load_ua_settings() {
|
| 117 |
-
$gravity_forms_add_on_settings = get_option( 'gravityformsaddon_gravity-forms-event-tracking_settings', array() );
|
| 118 |
-
|
| 119 |
-
$this->ua_id = $ua_id = false;
|
| 120 |
-
|
| 121 |
-
if ( !isset( $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua' ] ) ) {
|
| 122 |
-
$ua_id = get_option('gravity_forms_event_tracking_ua', false ); //Backwards compat
|
| 123 |
-
}
|
| 124 |
-
else {
|
| 125 |
-
$ua_id = $gravity_forms_add_on_settings[ 'gravity_forms_event_tracking_ua' ];
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
$ua_regex = "/^UA-[0-9]{5,}-[0-9]{1,}$/";
|
| 129 |
-
|
| 130 |
-
if ( preg_match( $ua_regex, $ua_id ) ) {
|
| 131 |
-
$this->ua_id = $ua_id;
|
| 132 |
-
return true;
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
if (!$this->ua_id)
|
| 136 |
-
return false;
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
/**
|
| 140 |
-
* Load the google measurement protocol PHP client.
|
| 141 |
-
*
|
| 142 |
-
* @since 1.4.0
|
| 143 |
-
*/
|
| 144 |
-
private function load_measurement_client() {
|
| 145 |
-
|
| 146 |
-
require_once( 'includes/ga-mp/src/Racecore/GATracking/Autoloader.php');
|
| 147 |
-
Racecore\GATracking\Autoloader::register(dirname(__FILE__).'/includes/ga-mp/src/');
|
| 148 |
-
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
/**
|
| 152 |
-
* Handle the form after submission before sending to the event push
|
| 153 |
-
*
|
| 154 |
-
* @since 1.4.0
|
| 155 |
-
* @param array $entry Gravity Forms entry object
|
| 156 |
-
* @param array $form Gravity Forms form object
|
| 157 |
-
*/
|
| 158 |
-
public function track_form_after_submission( $entry, $form ) {
|
| 159 |
-
|
| 160 |
-
// Temporary until Gravity fix a bug
|
| 161 |
-
$entry = GFAPI::get_entry( $entry['id'] );
|
| 162 |
-
|
| 163 |
-
// We need to check if this form is using paypal standard before we push a conversion.
|
| 164 |
-
if ( class_exists( 'GFPayPal' ) ) {
|
| 165 |
-
$paypal = GFPayPal::get_instance();
|
| 166 |
-
|
| 167 |
-
// See if a PayPal standard feed exists for this form and the condition is met.
|
| 168 |
-
// If it is we need to save the GA cookie to the entry instead for return from the IPN
|
| 169 |
-
if ( $feed = $paypal->get_payment_feed( $entry ) && $paypal->is_feed_condition_met( $feed, $form, $entry ) ) {
|
| 170 |
-
gform_update_meta( $entry['id'], 'ga_cookie', $_COOKIE['_ga'] );
|
| 171 |
-
return;
|
| 172 |
-
}
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
// Push the event to google
|
| 176 |
-
$this->push_event( $entry, $form );
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
/**
|
| 180 |
-
* Handle the IPN response for pushing the event
|
| 181 |
-
*
|
| 182 |
-
* @since 1.4.0
|
| 183 |
-
* @param array $post_object global post array from the IPN
|
| 184 |
-
* @param array $entry Gravity Forms entry object
|
| 185 |
-
*/
|
| 186 |
-
public function paypal_track_form_post_ipn( $post_object, $entry ) {
|
| 187 |
-
// Check if the payment was completed before continuing
|
| 188 |
-
if ( strtolower( $entry['payment_status'] ) != 'paid' ) {
|
| 189 |
-
return;
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
// Fetch the cookie we saved previously and set it into the cookie global
|
| 193 |
-
// The php analytics library looks for this
|
| 194 |
-
$_COOKIE['_ga'] = gform_get_meta( $entry['id'], 'ga_cookie' );
|
| 195 |
-
|
| 196 |
-
$form = GFFormsModel::get_form_meta( $entry['form_id'] );
|
| 197 |
-
|
| 198 |
-
// Push the event to google
|
| 199 |
-
$this->push_event( $entry, $form );
|
| 200 |
-
}
|
| 201 |
-
|
| 202 |
-
/**
|
| 203 |
-
* Push the Google Analytics Event!
|
| 204 |
-
*
|
| 205 |
-
* @since 1.4.0
|
| 206 |
-
* @param array $event Gravity Forms event object
|
| 207 |
-
* @param array $form Gravity Forms form object
|
| 208 |
-
*/
|
| 209 |
-
private function push_event( $entry, $form ) {
|
| 210 |
-
|
| 211 |
-
// Init tracking object
|
| 212 |
-
$this->tracking = new \Racecore\GATracking\GATracking( apply_filters( 'gform_ua_id', $this->ua_id, $form ), false );
|
| 213 |
-
$event = new \Racecore\GATracking\Tracking\Event();
|
| 214 |
-
|
| 215 |
-
// Get event defaults
|
| 216 |
-
$event_category = 'Forms';
|
| 217 |
-
$event_label = sprintf( "Form: %s ID: %s", $form['title'], $form['id'] );
|
| 218 |
-
$event_action = 'Submission';
|
| 219 |
-
|
| 220 |
-
// IF this form has payment, we should use that for the value
|
| 221 |
-
// as long a custom value hasn't been set
|
| 222 |
-
$event_value = $this->get_event_value( $entry, $form );
|
| 223 |
-
|
| 224 |
-
// Overwrite with Gravity Form Settings if necessary
|
| 225 |
-
if ( function_exists( 'rgar' ) ) {
|
| 226 |
-
// Event category
|
| 227 |
-
$gf_event_category = rgar( $form, 'gaEventCategory' );
|
| 228 |
-
if ( !empty( $gf_event_category ) ) {
|
| 229 |
-
$event_category = $gf_event_category;
|
| 230 |
-
}
|
| 231 |
-
|
| 232 |
-
// Event label
|
| 233 |
-
$gf_event_label = rgar( $form, 'gaEventLabel' );
|
| 234 |
-
if ( !empty( $gf_event_label ) ) {
|
| 235 |
-
$event_label = $gf_event_label;
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
// Event action
|
| 239 |
-
$gf_event_action = rgar( $form, 'gaEventAction' );
|
| 240 |
-
if ( !empty( $gf_event_action ) ) {
|
| 241 |
-
$event_action = $gf_event_action;
|
| 242 |
-
}
|
| 243 |
-
|
| 244 |
-
// Event value
|
| 245 |
-
$gf_event_value = rgar( $form, 'gaEventValue' );
|
| 246 |
-
if ( !empty( $gf_event_value ) ) {
|
| 247 |
-
$event_value = $gf_event_value;
|
| 248 |
-
}
|
| 249 |
-
}
|
| 250 |
-
|
| 251 |
-
// Set our event object variables
|
| 252 |
-
$event->setEventCategory( apply_filters( 'gform_event_category', $event_category, $form ) );
|
| 253 |
-
$event->setEventAction( apply_filters( 'gform_event_action', $event_action, $form ) );
|
| 254 |
-
$event->setEventLabel( apply_filters( 'gform_event_label', $event_label, $form ) );
|
| 255 |
-
|
| 256 |
-
if ( $event_value = apply_filters( 'gform_event_value', $event_value, $form ) ) {
|
| 257 |
-
$event->setEventValue( $event_value );
|
| 258 |
-
}
|
| 259 |
-
|
| 260 |
-
// Pppp Push it!
|
| 261 |
-
$this->tracking->addTracking( $event );
|
| 262 |
-
|
| 263 |
-
try {
|
| 264 |
-
$this->tracking->send();
|
| 265 |
-
} catch (Exception $e) {
|
| 266 |
-
echo 'Error: ' . $e->getMessage() . '<br />' . "\r\n";
|
| 267 |
-
echo 'Type: ' . get_class($e);
|
| 268 |
-
}
|
| 269 |
-
}
|
| 270 |
-
|
| 271 |
-
/**
|
| 272 |
-
* Get the event value for payment entries
|
| 273 |
-
*
|
| 274 |
-
* @since 1.4.0
|
| 275 |
-
* @param array $event Gravity Forms event object
|
| 276 |
-
* @return string/boolean Event value or false if not a payment form
|
| 277 |
-
*/
|
| 278 |
-
private function get_event_value( $entry ) {
|
| 279 |
-
$value = rgar( $entry, 'payment_amount' );
|
| 280 |
-
|
| 281 |
-
if ( ! empty( $value ) && intval( $value ) ) {
|
| 282 |
-
return intval( $value );
|
| 283 |
-
}
|
| 284 |
-
|
| 285 |
-
return false;
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Autoloader.php
DELETED
|
@@ -1,74 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking;
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Google Analytics Measurement PHP Class
|
| 6 |
-
* Licensed under the 3-clause BSD License.
|
| 7 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 8 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 9 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 10 |
-
*
|
| 11 |
-
* Google Documentation
|
| 12 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 13 |
-
*
|
| 14 |
-
* @author Marco Rieger
|
| 15 |
-
* @email Rieger(at)racecore.de
|
| 16 |
-
* @git https://github.com/ins0
|
| 17 |
-
* @url http://www.racecore.de
|
| 18 |
-
* @package Racecore\GATracking
|
| 19 |
-
*/
|
| 20 |
-
class Autoloader
|
| 21 |
-
{
|
| 22 |
-
private $folder;
|
| 23 |
-
|
| 24 |
-
/**
|
| 25 |
-
* Constructor
|
| 26 |
-
*
|
| 27 |
-
* @param string $folder
|
| 28 |
-
*/
|
| 29 |
-
public function __construct( $folder = null )
|
| 30 |
-
{
|
| 31 |
-
if ( ! $folder )
|
| 32 |
-
{
|
| 33 |
-
$folder = dirname(__FILE__) . '/..';
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
$this->folder = $folder;
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
/**
|
| 40 |
-
* Handel autoloading of classes
|
| 41 |
-
*
|
| 42 |
-
* @param $class
|
| 43 |
-
* @return bool|mixed
|
| 44 |
-
*/
|
| 45 |
-
public function autoload( $class )
|
| 46 |
-
{
|
| 47 |
-
$filePath = $this->folder . '/' . str_replace('\\', '/', $class) . '.php';
|
| 48 |
-
|
| 49 |
-
if (file_exists($filePath))
|
| 50 |
-
{
|
| 51 |
-
return ( (require_once $filePath) === false ? true : false );
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
return false;
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
/**
|
| 58 |
-
* Register SPL Autoload
|
| 59 |
-
*
|
| 60 |
-
* @param null $folder
|
| 61 |
-
* @return bool
|
| 62 |
-
*/
|
| 63 |
-
public static function register( $folder = null )
|
| 64 |
-
{
|
| 65 |
-
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
| 66 |
-
|
| 67 |
-
return spl_autoload_register(
|
| 68 |
-
array(
|
| 69 |
-
new self($folder),
|
| 70 |
-
'autoload'
|
| 71 |
-
)
|
| 72 |
-
);
|
| 73 |
-
}
|
| 74 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Exception.php
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking;
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Google Analytics Measurement PHP Class
|
| 6 |
-
* Licensed under the 3-clause BSD License.
|
| 7 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 8 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 9 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 10 |
-
*
|
| 11 |
-
* Google Documentation
|
| 12 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 13 |
-
*
|
| 14 |
-
* @author Marco Rieger
|
| 15 |
-
* @email Rieger(at)racecore.de
|
| 16 |
-
* @git https://github.com/ins0
|
| 17 |
-
* @url http://www.racecore.de
|
| 18 |
-
* @package Racecore\GATracking
|
| 19 |
-
*/
|
| 20 |
-
class Exception extends \UnexpectedValueException
|
| 21 |
-
{
|
| 22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Exception/EndpointServerException.php
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Exception;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception;
|
| 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\Exception
|
| 21 |
-
*/
|
| 22 |
-
class EndpointServerException extends Exception
|
| 23 |
-
{
|
| 24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Exception/MissingConfigurationException.php
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Exception;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception;
|
| 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\Exception
|
| 21 |
-
*/
|
| 22 |
-
class MissingConfigurationException extends Exception
|
| 23 |
-
{
|
| 24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Exception/MissingTrackingParameterException.php
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Exception;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception;
|
| 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\Exception
|
| 21 |
-
*/
|
| 22 |
-
class MissingTrackingParameterException extends Exception
|
| 23 |
-
{
|
| 24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/GATracking.php
DELETED
|
@@ -1,477 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception\EndpointServerException;
|
| 5 |
-
use Racecore\GATracking\Exception\MissingConfigurationException;
|
| 6 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 7 |
-
|
| 8 |
-
/**
|
| 9 |
-
* Google Analytics Measurement PHP Class
|
| 10 |
-
* Licensed under the 3-clause BSD License.
|
| 11 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 12 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 13 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 14 |
-
*
|
| 15 |
-
* Google Documentation
|
| 16 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 17 |
-
*
|
| 18 |
-
* @author Marco Rieger
|
| 19 |
-
* @email Rieger(at)racecore.de
|
| 20 |
-
* @git https://github.com/ins0
|
| 21 |
-
* @url http://www.racecore.de
|
| 22 |
-
* @package Racecore\GATracking\Tracking
|
| 23 |
-
*/
|
| 24 |
-
class GATracking
|
| 25 |
-
{
|
| 26 |
-
/**
|
| 27 |
-
* Google Analytics Account ID UA-...
|
| 28 |
-
*
|
| 29 |
-
* @var
|
| 30 |
-
*/
|
| 31 |
-
private $accountID;
|
| 32 |
-
|
| 33 |
-
/**
|
| 34 |
-
* Current User Client ID
|
| 35 |
-
*
|
| 36 |
-
* @var string
|
| 37 |
-
*/
|
| 38 |
-
private $clientID;
|
| 39 |
-
|
| 40 |
-
/**
|
| 41 |
-
* Current User ID
|
| 42 |
-
*
|
| 43 |
-
* @var string
|
| 44 |
-
*/
|
| 45 |
-
private $userID = null;
|
| 46 |
-
|
| 47 |
-
/**
|
| 48 |
-
* Protocol Version
|
| 49 |
-
*
|
| 50 |
-
* @var string
|
| 51 |
-
*/
|
| 52 |
-
private $protocol = '1';
|
| 53 |
-
|
| 54 |
-
/**
|
| 55 |
-
* Analytics Endpoint URL
|
| 56 |
-
*
|
| 57 |
-
* @var string
|
| 58 |
-
*/
|
| 59 |
-
private $analytics_endpoint = 'http://www.google-analytics.com/collect';
|
| 60 |
-
|
| 61 |
-
/**
|
| 62 |
-
* Tacking Holder
|
| 63 |
-
*
|
| 64 |
-
* @var array
|
| 65 |
-
*/
|
| 66 |
-
private $tracking_holder = array();
|
| 67 |
-
|
| 68 |
-
/**
|
| 69 |
-
* Holds the last Response from Google Analytics Server
|
| 70 |
-
*
|
| 71 |
-
* @var string
|
| 72 |
-
*/
|
| 73 |
-
private $last_response = null;
|
| 74 |
-
|
| 75 |
-
/**
|
| 76 |
-
* Holds all Responses from GA Server
|
| 77 |
-
*
|
| 78 |
-
* @var array
|
| 79 |
-
*/
|
| 80 |
-
private $last_response_stack = array();
|
| 81 |
-
|
| 82 |
-
/**
|
| 83 |
-
* Send Proxy Variables
|
| 84 |
-
*
|
| 85 |
-
* @var boolean
|
| 86 |
-
*/
|
| 87 |
-
private $use_proxy;
|
| 88 |
-
|
| 89 |
-
/**
|
| 90 |
-
* Sets the Use Proxy variable
|
| 91 |
-
*
|
| 92 |
-
* @param $proxy
|
| 93 |
-
*/
|
| 94 |
-
public function setProxy($proxy)
|
| 95 |
-
{
|
| 96 |
-
$this->use_proxy = $proxy;
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
/**
|
| 100 |
-
* Returns the Use Proxy variable
|
| 101 |
-
*
|
| 102 |
-
* @return boolean
|
| 103 |
-
*/
|
| 104 |
-
public function getProxy()
|
| 105 |
-
{
|
| 106 |
-
return $this->use_proxy;
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
/**
|
| 110 |
-
* Sets the Analytics Account ID
|
| 111 |
-
*
|
| 112 |
-
* @param $account
|
| 113 |
-
*/
|
| 114 |
-
public function setAccountID($account)
|
| 115 |
-
{
|
| 116 |
-
|
| 117 |
-
$this->accountID = $account;
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
/**
|
| 121 |
-
* Set the current Client ID
|
| 122 |
-
*
|
| 123 |
-
* @param $clientID
|
| 124 |
-
* @return $this
|
| 125 |
-
*/
|
| 126 |
-
public function setClientID($clientID)
|
| 127 |
-
{
|
| 128 |
-
$this->clientID = $clientID;
|
| 129 |
-
return $this;
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
/**
|
| 133 |
-
* Returns the current Client ID
|
| 134 |
-
*
|
| 135 |
-
* @return string
|
| 136 |
-
*/
|
| 137 |
-
public function getClientID()
|
| 138 |
-
{
|
| 139 |
-
if (!$this->clientID) {
|
| 140 |
-
$this->clientID = $this->createClientID();
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
return $this->clientID;
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
/**
|
| 147 |
-
* Set the current User ID
|
| 148 |
-
*
|
| 149 |
-
* @param $clientID
|
| 150 |
-
* @return $this
|
| 151 |
-
*/
|
| 152 |
-
public function setUserID($userID)
|
| 153 |
-
{
|
| 154 |
-
$this->userID = $userID;
|
| 155 |
-
return $this;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
/**
|
| 159 |
-
* Returns the current User ID
|
| 160 |
-
*
|
| 161 |
-
* @return string
|
| 162 |
-
*/
|
| 163 |
-
public function getUserID()
|
| 164 |
-
{
|
| 165 |
-
return $this->userID;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
/**
|
| 169 |
-
* Return all registered Events
|
| 170 |
-
*
|
| 171 |
-
* @return array
|
| 172 |
-
*/
|
| 173 |
-
public function getEvents()
|
| 174 |
-
{
|
| 175 |
-
return $this->tracking_holder;
|
| 176 |
-
}
|
| 177 |
-
|
| 178 |
-
/**
|
| 179 |
-
* Returns current Google Account ID
|
| 180 |
-
*
|
| 181 |
-
* @return mixed
|
| 182 |
-
*/
|
| 183 |
-
public function getAccountID()
|
| 184 |
-
{
|
| 185 |
-
return $this->accountID;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
/**
|
| 189 |
-
* Constructor
|
| 190 |
-
*
|
| 191 |
-
* @param string $accountID
|
| 192 |
-
* @param boolean $proxy (default: false)
|
| 193 |
-
*/
|
| 194 |
-
public function __construct( $accountID = null, $proxy = false )
|
| 195 |
-
{
|
| 196 |
-
$this->setAccountID( $accountID );
|
| 197 |
-
$this->setProxy($proxy);
|
| 198 |
-
|
| 199 |
-
return $this;
|
| 200 |
-
}
|
| 201 |
-
|
| 202 |
-
/**
|
| 203 |
-
* Create a GUID on Client specific values
|
| 204 |
-
*
|
| 205 |
-
* @return string
|
| 206 |
-
*/
|
| 207 |
-
private function createClientID()
|
| 208 |
-
{
|
| 209 |
-
// collect user specific data
|
| 210 |
-
if (isset($_COOKIE['_ga'])) {
|
| 211 |
-
|
| 212 |
-
$gaCookie = explode('.', $_COOKIE['_ga']);
|
| 213 |
-
if( isset($gaCookie[2] ) )
|
| 214 |
-
{
|
| 215 |
-
// check if uuid
|
| 216 |
-
if( $this->checkUUID( $gaCookie[2] ) )
|
| 217 |
-
{
|
| 218 |
-
// uuid set in cookie
|
| 219 |
-
return $gaCookie[2];
|
| 220 |
-
}
|
| 221 |
-
elseif( isset($gaCookie[2]) && isset($gaCookie[3]) )
|
| 222 |
-
{
|
| 223 |
-
// google default client id
|
| 224 |
-
return $gaCookie[2] . '.' . $gaCookie[3];
|
| 225 |
-
}
|
| 226 |
-
}
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
// nothing found - return random uuid client id
|
| 230 |
-
return $this->generateUUID();
|
| 231 |
-
}
|
| 232 |
-
|
| 233 |
-
/**
|
| 234 |
-
* Check if is a valid UUID v4
|
| 235 |
-
*
|
| 236 |
-
* @param $uuid
|
| 237 |
-
* @return int
|
| 238 |
-
*/
|
| 239 |
-
private function checkUUID( $uuid )
|
| 240 |
-
{
|
| 241 |
-
return preg_match('#^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$#i', $uuid );
|
| 242 |
-
}
|
| 243 |
-
|
| 244 |
-
/**
|
| 245 |
-
* Generate UUID v4 function - needed to generate a CID when one isn't available
|
| 246 |
-
*
|
| 247 |
-
* @author Andrew Moore http://www.php.net/manual/en/function.uniqid.php#94959
|
| 248 |
-
* @return string
|
| 249 |
-
*/
|
| 250 |
-
private function generateUUID() {
|
| 251 |
-
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
| 252 |
-
// 32 bits for "time_low"
|
| 253 |
-
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
|
| 254 |
-
|
| 255 |
-
// 16 bits for "time_mid"
|
| 256 |
-
mt_rand( 0, 0xffff ),
|
| 257 |
-
|
| 258 |
-
// 16 bits for "time_hi_and_version",
|
| 259 |
-
// four most significant bits holds version number 4
|
| 260 |
-
mt_rand( 0, 0x0fff ) | 0x4000,
|
| 261 |
-
|
| 262 |
-
// 16 bits, 8 bits for "clk_seq_hi_res",
|
| 263 |
-
// 8 bits for "clk_seq_low",
|
| 264 |
-
// two most significant bits holds zero and one for variant DCE1.1
|
| 265 |
-
mt_rand( 0, 0x3fff ) | 0x8000,
|
| 266 |
-
|
| 267 |
-
// 48 bits for "node"
|
| 268 |
-
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
|
| 269 |
-
);
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
/**
|
| 273 |
-
* Send all captured Trackings to Analytics Server
|
| 274 |
-
* Flush all prev. captured tracking responses
|
| 275 |
-
*
|
| 276 |
-
* @return bool
|
| 277 |
-
*/
|
| 278 |
-
public function send()
|
| 279 |
-
{
|
| 280 |
-
// clear response logs
|
| 281 |
-
$this->last_response_stack = array();
|
| 282 |
-
$this->last_response = null;
|
| 283 |
-
|
| 284 |
-
/** @var AbstractTracking $event */
|
| 285 |
-
foreach ($this->tracking_holder as $tracking) {
|
| 286 |
-
$this->sendTracking($tracking);
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
return true;
|
| 290 |
-
}
|
| 291 |
-
|
| 292 |
-
/**
|
| 293 |
-
* Returns the Client IP
|
| 294 |
-
* The last octect of the IP address is removed to anonymize the user
|
| 295 |
-
*
|
| 296 |
-
* @param string $address
|
| 297 |
-
* @return string
|
| 298 |
-
*/
|
| 299 |
-
function getClientIP($address = '')
|
| 300 |
-
{
|
| 301 |
-
|
| 302 |
-
if (!$address) {
|
| 303 |
-
$address = $_SERVER['REMOTE_ADDR'];
|
| 304 |
-
}
|
| 305 |
-
|
| 306 |
-
if (!$address) {
|
| 307 |
-
return '';
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
// Capture the first three octects of the IP address and replace the forth
|
| 311 |
-
// with 0, e.g. 124.455.3.123 becomes 124.455.3.0
|
| 312 |
-
$regex = "/^([^.]+\.[^.]+\.[^.]+\.).*/";
|
| 313 |
-
if (preg_match($regex, $address, $matches)) {
|
| 314 |
-
return $matches[1] . '0';
|
| 315 |
-
}
|
| 316 |
-
|
| 317 |
-
return '';
|
| 318 |
-
}
|
| 319 |
-
|
| 320 |
-
/**
|
| 321 |
-
* Build the POST Packet
|
| 322 |
-
*
|
| 323 |
-
* @param AbstractTracking $event
|
| 324 |
-
* @return string
|
| 325 |
-
* @throws Exception\MissingConfigurationException
|
| 326 |
-
*/
|
| 327 |
-
private function buildPacket( AbstractTracking $event )
|
| 328 |
-
{
|
| 329 |
-
// get packet
|
| 330 |
-
$eventPacket = $event->getPaket();
|
| 331 |
-
|
| 332 |
-
if( ! $this->getAccountID() )
|
| 333 |
-
{
|
| 334 |
-
throw new MissingConfigurationException('Google Account ID is missing');
|
| 335 |
-
}
|
| 336 |
-
|
| 337 |
-
// Add Protocol
|
| 338 |
-
$eventPacket['v'] = $this->protocol; // protocol version
|
| 339 |
-
$eventPacket['tid'] = $this->getAccountID(); // account id
|
| 340 |
-
$eventPacket['cid'] = $this->getClientID(); // client id
|
| 341 |
-
|
| 342 |
-
if($this->getUserID() != null){
|
| 343 |
-
$eventPacket['uid'] = $this->getUserID();
|
| 344 |
-
}
|
| 345 |
-
|
| 346 |
-
//Proxy Variables
|
| 347 |
-
if($this->getProxy()){
|
| 348 |
-
$eventPacket['uip'] = $_SERVER['REMOTE_ADDR']; // IP Override
|
| 349 |
-
$eventPacket['ua'] = $_SERVER['HTTP_USER_AGENT']; // UA Override
|
| 350 |
-
}
|
| 351 |
-
|
| 352 |
-
$eventPacket = array_reverse($eventPacket);
|
| 353 |
-
|
| 354 |
-
// build query
|
| 355 |
-
return http_build_query($eventPacket);
|
| 356 |
-
}
|
| 357 |
-
|
| 358 |
-
/**
|
| 359 |
-
* Send an Event to Google Analytics
|
| 360 |
-
* Will be removed
|
| 361 |
-
*
|
| 362 |
-
* @param AbstractTracking $tracking
|
| 363 |
-
* @return bool
|
| 364 |
-
* @throws Exception\EndpointServerException
|
| 365 |
-
* @deprecated Use sendTracking
|
| 366 |
-
*/
|
| 367 |
-
public function sendEvent(AbstractTracking $tracking)
|
| 368 |
-
{
|
| 369 |
-
return $this->sendTracking($tracking);
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
/**
|
| 373 |
-
* Send an Event to Google Analytics
|
| 374 |
-
*
|
| 375 |
-
* @param AbstractTracking $event
|
| 376 |
-
* @return bool
|
| 377 |
-
* @throws Exception\EndpointServerException
|
| 378 |
-
*/
|
| 379 |
-
public function sendTracking(AbstractTracking $event)
|
| 380 |
-
{
|
| 381 |
-
// get packet
|
| 382 |
-
$eventPacket = $this->buildPacket( $event );
|
| 383 |
-
|
| 384 |
-
// get endpoint
|
| 385 |
-
$endpoint = parse_url($this->analytics_endpoint);
|
| 386 |
-
|
| 387 |
-
// port
|
| 388 |
-
$port = ($endpoint['scheme'] == 'https' ? 443 : 80);
|
| 389 |
-
|
| 390 |
-
// connect
|
| 391 |
-
$connection = @fsockopen($endpoint['scheme'] == 'https' ? 'ssl://' : $endpoint['host'], $port, $error, $errorstr, 10);
|
| 392 |
-
|
| 393 |
-
if (!$connection) {
|
| 394 |
-
throw new EndpointServerException('Analytics Host not reachable!');
|
| 395 |
-
}
|
| 396 |
-
|
| 397 |
-
$header = 'POST ' . $endpoint['path'] . ' HTTP/1.1' . "\r\n" .
|
| 398 |
-
'Host: ' . $endpoint['host'] . "\r\n" .
|
| 399 |
-
'User-Agent: Google-Measurement-PHP-Client' . "\r\n" .
|
| 400 |
-
'Content-Type: application/x-www-form-urlencoded' . "\r\n" .
|
| 401 |
-
'Content-Length: ' . strlen($eventPacket) . "\r\n" .
|
| 402 |
-
'Connection: Close' . "\r\n\r\n";
|
| 403 |
-
|
| 404 |
-
$this->last_response = '';
|
| 405 |
-
|
| 406 |
-
// frwite data
|
| 407 |
-
fwrite($connection, $header);
|
| 408 |
-
fwrite($connection, $eventPacket);
|
| 409 |
-
|
| 410 |
-
// response
|
| 411 |
-
$response = '';
|
| 412 |
-
|
| 413 |
-
// receive response
|
| 414 |
-
while (!feof($connection)) {
|
| 415 |
-
$response .= fgets($connection, 1024);
|
| 416 |
-
}
|
| 417 |
-
|
| 418 |
-
// response
|
| 419 |
-
$responseContainer = explode("\r\n\r\n", $response, 2);
|
| 420 |
-
$responseContainer[0] = explode("\r\n", $responseContainer[0]);
|
| 421 |
-
|
| 422 |
-
// save last response
|
| 423 |
-
$this->addResponse( $responseContainer );
|
| 424 |
-
|
| 425 |
-
// connection close
|
| 426 |
-
fclose($connection);
|
| 427 |
-
|
| 428 |
-
return true;
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
-
/**
|
| 432 |
-
* Add a Response to the Stack
|
| 433 |
-
*
|
| 434 |
-
* @param $response
|
| 435 |
-
* @return bool
|
| 436 |
-
*/
|
| 437 |
-
public function addResponse( $response )
|
| 438 |
-
{
|
| 439 |
-
$this->last_response_stack[] = $response;
|
| 440 |
-
$this->last_response = $response;
|
| 441 |
-
return true;
|
| 442 |
-
}
|
| 443 |
-
|
| 444 |
-
/**
|
| 445 |
-
* Returns the last Response from Google Analytics Server
|
| 446 |
-
*
|
| 447 |
-
* @author Marco Rieger
|
| 448 |
-
* @return string
|
| 449 |
-
*/
|
| 450 |
-
public function getLastResponse()
|
| 451 |
-
{
|
| 452 |
-
return $this->last_response;
|
| 453 |
-
}
|
| 454 |
-
|
| 455 |
-
/**
|
| 456 |
-
* Returns all Responses since the last Send Method Call
|
| 457 |
-
*
|
| 458 |
-
* @return array
|
| 459 |
-
*/
|
| 460 |
-
public function getLastResponseStack()
|
| 461 |
-
{
|
| 462 |
-
return $this->last_response_stack;
|
| 463 |
-
}
|
| 464 |
-
|
| 465 |
-
/**
|
| 466 |
-
* Add Tracking Event
|
| 467 |
-
*
|
| 468 |
-
* @param AbstractTracking $tracking
|
| 469 |
-
* @return $this
|
| 470 |
-
*/
|
| 471 |
-
public function addTracking(AbstractTracking $tracking)
|
| 472 |
-
{
|
| 473 |
-
$this->tracking_holder[] = $tracking;
|
| 474 |
-
|
| 475 |
-
return $this;
|
| 476 |
-
}
|
| 477 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/AbstractTracking.php
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking;
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Google Analytics Measurement PHP Class
|
| 6 |
-
* Licensed under the 3-clause BSD License.
|
| 7 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 8 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 9 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 10 |
-
*
|
| 11 |
-
* Google Documentation
|
| 12 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 13 |
-
*
|
| 14 |
-
* @author Marco Rieger
|
| 15 |
-
* @email Rieger(at)racecore.de
|
| 16 |
-
* @git https://github.com/ins0
|
| 17 |
-
* @url http://www.racecore.de
|
| 18 |
-
* @package Racecore\GATracking\Tracking
|
| 19 |
-
*/
|
| 20 |
-
abstract class AbstractTracking
|
| 21 |
-
{
|
| 22 |
-
|
| 23 |
-
/**
|
| 24 |
-
* Get the transfer Paket from current Event
|
| 25 |
-
*
|
| 26 |
-
* @return array
|
| 27 |
-
*/
|
| 28 |
-
abstract public function getPaket();
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/App/Event.php
DELETED
|
@@ -1,107 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking\App;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 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\App
|
| 21 |
-
*/
|
| 22 |
-
class Event extends AbstractTracking
|
| 23 |
-
{
|
| 24 |
-
/** @var string */
|
| 25 |
-
private $appName;
|
| 26 |
-
|
| 27 |
-
/** @var string */
|
| 28 |
-
private $eventCategory;
|
| 29 |
-
|
| 30 |
-
/** @var string */
|
| 31 |
-
private $eventAction;
|
| 32 |
-
|
| 33 |
-
/**
|
| 34 |
-
* Set the Application Name
|
| 35 |
-
*
|
| 36 |
-
* @param string $appName
|
| 37 |
-
*/
|
| 38 |
-
public function setAppName($appName)
|
| 39 |
-
{
|
| 40 |
-
$this->appName = $appName;
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
/**
|
| 44 |
-
* Get the Application Name
|
| 45 |
-
*
|
| 46 |
-
* @return string
|
| 47 |
-
*/
|
| 48 |
-
public function getAppName()
|
| 49 |
-
{
|
| 50 |
-
return $this->appName;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
/**
|
| 54 |
-
* Set the Event Action
|
| 55 |
-
*
|
| 56 |
-
* @param string $eventAction
|
| 57 |
-
*/
|
| 58 |
-
public function setEventAction($eventAction)
|
| 59 |
-
{
|
| 60 |
-
$this->eventAction = $eventAction;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
/**
|
| 64 |
-
* Get the Event Action
|
| 65 |
-
*
|
| 66 |
-
* @return string
|
| 67 |
-
*/
|
| 68 |
-
public function getEventAction()
|
| 69 |
-
{
|
| 70 |
-
return $this->eventAction;
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
/**
|
| 74 |
-
* Set the Event Category
|
| 75 |
-
*
|
| 76 |
-
* @param string $eventCategory
|
| 77 |
-
*/
|
| 78 |
-
public function setEventCategory($eventCategory)
|
| 79 |
-
{
|
| 80 |
-
$this->eventCategory = $eventCategory;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
/**
|
| 84 |
-
* Get the Event Category
|
| 85 |
-
*
|
| 86 |
-
* @return string
|
| 87 |
-
*/
|
| 88 |
-
public function getEventCategory()
|
| 89 |
-
{
|
| 90 |
-
return $this->eventCategory;
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
/**
|
| 94 |
-
* Returns the Paket for App Event Tracking
|
| 95 |
-
*
|
| 96 |
-
* @return array
|
| 97 |
-
*/
|
| 98 |
-
public function getPaket()
|
| 99 |
-
{
|
| 100 |
-
return array(
|
| 101 |
-
't' => 'event',
|
| 102 |
-
'an' => $this->getAppName(),
|
| 103 |
-
'ec' => $this->getEventCategory(),
|
| 104 |
-
'ea' => $this->getEventAction()
|
| 105 |
-
);
|
| 106 |
-
}
|
| 107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/App/Screen.php
DELETED
|
@@ -1,107 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking\App;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 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\App
|
| 21 |
-
*/
|
| 22 |
-
class Screen extends AbstractTracking
|
| 23 |
-
{
|
| 24 |
-
/** @var string */
|
| 25 |
-
private $appName;
|
| 26 |
-
|
| 27 |
-
/** @var string */
|
| 28 |
-
private $appVersion;
|
| 29 |
-
|
| 30 |
-
/** @var string */
|
| 31 |
-
private $contentDescription;
|
| 32 |
-
|
| 33 |
-
/**
|
| 34 |
-
* Set the Application Name
|
| 35 |
-
*
|
| 36 |
-
* @param string $appName
|
| 37 |
-
*/
|
| 38 |
-
public function setAppName($appName)
|
| 39 |
-
{
|
| 40 |
-
$this->appName = $appName;
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
/**
|
| 44 |
-
* Get the Application Name
|
| 45 |
-
*
|
| 46 |
-
* @return string
|
| 47 |
-
*/
|
| 48 |
-
public function getAppName()
|
| 49 |
-
{
|
| 50 |
-
return $this->appName;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
/**
|
| 54 |
-
* Set the Application Version
|
| 55 |
-
*
|
| 56 |
-
* @param string $appVersion
|
| 57 |
-
*/
|
| 58 |
-
public function setAppVersion($appVersion)
|
| 59 |
-
{
|
| 60 |
-
$this->appVersion = $appVersion;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
/**
|
| 64 |
-
* Get the Application Version
|
| 65 |
-
*
|
| 66 |
-
* @return string
|
| 67 |
-
*/
|
| 68 |
-
public function getAppVersion()
|
| 69 |
-
{
|
| 70 |
-
return $this->appVersion;
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
/**
|
| 74 |
-
* Set the Content Description/Screen Name
|
| 75 |
-
*
|
| 76 |
-
* @param string $contentDescription
|
| 77 |
-
*/
|
| 78 |
-
public function setContentDescription($contentDescription)
|
| 79 |
-
{
|
| 80 |
-
$this->contentDescription = $contentDescription;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
/**
|
| 84 |
-
* Get the Content Description/Screen Name
|
| 85 |
-
*
|
| 86 |
-
* @return string
|
| 87 |
-
*/
|
| 88 |
-
public function getContentDescription()
|
| 89 |
-
{
|
| 90 |
-
return $this->contentDescription;
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
/**
|
| 94 |
-
* Returns the Paket for App Screen Tracking
|
| 95 |
-
*
|
| 96 |
-
* @return array
|
| 97 |
-
*/
|
| 98 |
-
public function getPaket()
|
| 99 |
-
{
|
| 100 |
-
return array(
|
| 101 |
-
't' => 'appview',
|
| 102 |
-
'an' => $this->getAppName(),
|
| 103 |
-
'av' => $this->getAppVersion(),
|
| 104 |
-
'cd' => $this->getContentDescription()
|
| 105 |
-
);
|
| 106 |
-
}
|
| 107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Item.php
DELETED
|
@@ -1,230 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking\Ecommerce;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception\MissingTrackingParameterException;
|
| 5 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 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 Enea Berti
|
| 18 |
-
* @email reysharks(at)gmail.com
|
| 19 |
-
* @git https://github.com/reysharks
|
| 20 |
-
* @url http://www.adacto.it
|
| 21 |
-
* @package Racecore\GATracking\Tracking
|
| 22 |
-
*/
|
| 23 |
-
class Item extends AbstractTracking
|
| 24 |
-
{
|
| 25 |
-
|
| 26 |
-
private $tid = 0;
|
| 27 |
-
private $name = '';
|
| 28 |
-
private $price = 0;
|
| 29 |
-
private $quantity = 0;
|
| 30 |
-
private $sku = '';
|
| 31 |
-
private $category = '';
|
| 32 |
-
private $currency = '';
|
| 33 |
-
|
| 34 |
-
/**
|
| 35 |
-
* Set the Transaction ID
|
| 36 |
-
*
|
| 37 |
-
* @param $id
|
| 38 |
-
*/
|
| 39 |
-
public function setTransactionID($tid)
|
| 40 |
-
{
|
| 41 |
-
|
| 42 |
-
$this->tid = $tid;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
/**
|
| 46 |
-
* Returns the Transaction ID
|
| 47 |
-
*
|
| 48 |
-
* @return integer
|
| 49 |
-
*/
|
| 50 |
-
public function getTransactionID()
|
| 51 |
-
{
|
| 52 |
-
|
| 53 |
-
if (!$this->tid) {
|
| 54 |
-
return '/';
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
return $this->tid;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
/**
|
| 61 |
-
* Sets the Item Name
|
| 62 |
-
*
|
| 63 |
-
* @param $name
|
| 64 |
-
*/
|
| 65 |
-
public function setName($name)
|
| 66 |
-
{
|
| 67 |
-
|
| 68 |
-
$this->name = $name;
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
/**
|
| 72 |
-
* Return Name
|
| 73 |
-
*
|
| 74 |
-
* @return string
|
| 75 |
-
*/
|
| 76 |
-
public function getName()
|
| 77 |
-
{
|
| 78 |
-
|
| 79 |
-
if (!$this->name) {
|
| 80 |
-
return $this->sku;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
return $this->name;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
/**
|
| 87 |
-
* Sets the Item Price
|
| 88 |
-
*
|
| 89 |
-
* @param $price
|
| 90 |
-
*/
|
| 91 |
-
public function setPrice($price)
|
| 92 |
-
{
|
| 93 |
-
$this->price = $price;
|
| 94 |
-
}
|
| 95 |
-
|
| 96 |
-
/**
|
| 97 |
-
* Return the Price
|
| 98 |
-
*
|
| 99 |
-
* @return float
|
| 100 |
-
*/
|
| 101 |
-
public function getPrice()
|
| 102 |
-
{
|
| 103 |
-
return $this->price;
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
/**
|
| 107 |
-
* Sets the Quantity
|
| 108 |
-
*
|
| 109 |
-
* @param $quantity
|
| 110 |
-
*/
|
| 111 |
-
public function setQuantity($quantity)
|
| 112 |
-
{
|
| 113 |
-
$this->quantity = $quantity;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
/**
|
| 117 |
-
* Return Quantity
|
| 118 |
-
*
|
| 119 |
-
* @return integer
|
| 120 |
-
*/
|
| 121 |
-
public function getQuantity()
|
| 122 |
-
{
|
| 123 |
-
return $this->quantity;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
/**
|
| 127 |
-
* Sets the Sku
|
| 128 |
-
*
|
| 129 |
-
* @param $sku
|
| 130 |
-
*/
|
| 131 |
-
public function setSku($sku)
|
| 132 |
-
{
|
| 133 |
-
$this->sku = $sku;
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
/**
|
| 137 |
-
* Return the Sku
|
| 138 |
-
*
|
| 139 |
-
* @return float
|
| 140 |
-
*/
|
| 141 |
-
public function getSku()
|
| 142 |
-
{
|
| 143 |
-
return $this->sku;
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
/**
|
| 147 |
-
* Sets the Category
|
| 148 |
-
*
|
| 149 |
-
* @param $category
|
| 150 |
-
*/
|
| 151 |
-
public function setCategory($category)
|
| 152 |
-
{
|
| 153 |
-
$this->category = $category;
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
-
/**
|
| 157 |
-
* Return the Category
|
| 158 |
-
*
|
| 159 |
-
* @return float
|
| 160 |
-
*/
|
| 161 |
-
public function getCategory()
|
| 162 |
-
{
|
| 163 |
-
return $this->category;
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
/**
|
| 167 |
-
* Sets the Currency
|
| 168 |
-
*
|
| 169 |
-
* @param $currency
|
| 170 |
-
*/
|
| 171 |
-
public function setCurrency($currency)
|
| 172 |
-
{
|
| 173 |
-
$this->currency = $currency;
|
| 174 |
-
}
|
| 175 |
-
|
| 176 |
-
/**
|
| 177 |
-
* Return the Currency
|
| 178 |
-
*
|
| 179 |
-
* @return string
|
| 180 |
-
*/
|
| 181 |
-
public function getCurrency()
|
| 182 |
-
{
|
| 183 |
-
return $this->currency;
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
public function setTransactionHost($host)
|
| 187 |
-
{
|
| 188 |
-
$this->host = $host;
|
| 189 |
-
return $this;
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
/**
|
| 193 |
-
* @return string
|
| 194 |
-
*/
|
| 195 |
-
public function getTransactionHost()
|
| 196 |
-
{
|
| 197 |
-
return $this->host;
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
/**
|
| 201 |
-
* Returns the Google Paket for Item Tracking
|
| 202 |
-
*
|
| 203 |
-
* @return array
|
| 204 |
-
*/
|
| 205 |
-
public function getPaket()
|
| 206 |
-
{
|
| 207 |
-
if( !$this->getTransactionID() )
|
| 208 |
-
{
|
| 209 |
-
throw new MissingTrackingParameterException('transaction id is missing');
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
if( !$this->getName() )
|
| 213 |
-
{
|
| 214 |
-
throw new MissingTrackingParameterException('item name is missing');
|
| 215 |
-
}
|
| 216 |
-
|
| 217 |
-
return array(
|
| 218 |
-
't' => 'item',
|
| 219 |
-
'ti' => $this->getTransactionID(),
|
| 220 |
-
'in' => $this->getName(),
|
| 221 |
-
'ip' => $this->getPrice(),
|
| 222 |
-
'iq' => $this->getQuantity(),
|
| 223 |
-
'ic' => $this->getSku(),
|
| 224 |
-
'iv' => $this->getCategory(),
|
| 225 |
-
'dh' => $this->getTransactionHost(),
|
| 226 |
-
'cu' => $this->getCurrency()
|
| 227 |
-
);
|
| 228 |
-
}
|
| 229 |
-
|
| 230 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/Ecommerce/Transaction.php
DELETED
|
@@ -1,209 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking\Ecommerce;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Exception\MissingTrackingParameterException;
|
| 5 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 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 Enea Berti
|
| 18 |
-
* @email reysharks(at)gmail.com
|
| 19 |
-
* @git https://github.com/reysharks
|
| 20 |
-
* @url http://www.adacto.it
|
| 21 |
-
* @package Racecore\GATracking\Tracking
|
| 22 |
-
*/
|
| 23 |
-
class Transaction extends AbstractTracking
|
| 24 |
-
{
|
| 25 |
-
|
| 26 |
-
private $id = 0;
|
| 27 |
-
private $affiliation = '';
|
| 28 |
-
private $revenue = 0;
|
| 29 |
-
private $shipping = 0;
|
| 30 |
-
private $tax = 0;
|
| 31 |
-
private $currency = '';
|
| 32 |
-
private $host = '';
|
| 33 |
-
|
| 34 |
-
/**
|
| 35 |
-
* Set the Transaction ID
|
| 36 |
-
*
|
| 37 |
-
* @param $id
|
| 38 |
-
*/
|
| 39 |
-
public function setID($id)
|
| 40 |
-
{
|
| 41 |
-
|
| 42 |
-
$this->id = $id;
|
| 43 |
-
}
|
| 44 |
-
|
| 45 |
-
/**
|
| 46 |
-
* Returns the Transaction ID
|
| 47 |
-
*
|
| 48 |
-
* @return integer
|
| 49 |
-
*/
|
| 50 |
-
public function getID()
|
| 51 |
-
{
|
| 52 |
-
|
| 53 |
-
if (!$this->id) {
|
| 54 |
-
return '/';
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
return $this->id;
|
| 58 |
-
}
|
| 59 |
-
|
| 60 |
-
/**
|
| 61 |
-
* Sets the Affiliation
|
| 62 |
-
*
|
| 63 |
-
* @param $affiliation
|
| 64 |
-
*/
|
| 65 |
-
public function setAffiliation($affiliation)
|
| 66 |
-
{
|
| 67 |
-
|
| 68 |
-
$this->affiliation = $affiliation;
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
/**
|
| 72 |
-
* Return Affiliation
|
| 73 |
-
*
|
| 74 |
-
* @return string
|
| 75 |
-
*/
|
| 76 |
-
public function getAffiliation()
|
| 77 |
-
{
|
| 78 |
-
|
| 79 |
-
return $this->affiliation;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
/**
|
| 83 |
-
* Sets the Revenue
|
| 84 |
-
*
|
| 85 |
-
* @param $revenue
|
| 86 |
-
*/
|
| 87 |
-
public function setRevenue($revenue)
|
| 88 |
-
{
|
| 89 |
-
$this->revenue = $revenue;
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
/**
|
| 93 |
-
* Return the Revenue
|
| 94 |
-
*
|
| 95 |
-
* @return float
|
| 96 |
-
*/
|
| 97 |
-
public function getRevenue()
|
| 98 |
-
{
|
| 99 |
-
return $this->revenue;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
* Sets the Shipping
|
| 104 |
-
*
|
| 105 |
-
* @param $shipping
|
| 106 |
-
*/
|
| 107 |
-
public function setShipping($shipping)
|
| 108 |
-
{
|
| 109 |
-
$this->shipping = $shipping;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
/**
|
| 113 |
-
* Return Shipping
|
| 114 |
-
*
|
| 115 |
-
* @return float
|
| 116 |
-
*/
|
| 117 |
-
public function getShipping()
|
| 118 |
-
{
|
| 119 |
-
return $this->shipping;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
/**
|
| 123 |
-
* Sets the Tax
|
| 124 |
-
*
|
| 125 |
-
* @param $tax
|
| 126 |
-
*/
|
| 127 |
-
public function setTax($tax)
|
| 128 |
-
{
|
| 129 |
-
$this->tax = $tax;
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
/**
|
| 133 |
-
* Return the Tax
|
| 134 |
-
*
|
| 135 |
-
* @return float
|
| 136 |
-
*/
|
| 137 |
-
public function getTax()
|
| 138 |
-
{
|
| 139 |
-
return $this->tax;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
/**
|
| 143 |
-
* Sets the Currency
|
| 144 |
-
*
|
| 145 |
-
* @param $currency
|
| 146 |
-
*/
|
| 147 |
-
public function setCurrency($currency)
|
| 148 |
-
{
|
| 149 |
-
$this->currency = $currency;
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
/**
|
| 153 |
-
* Return the Currency
|
| 154 |
-
*
|
| 155 |
-
* @return string
|
| 156 |
-
*/
|
| 157 |
-
public function getCurrency()
|
| 158 |
-
{
|
| 159 |
-
return $this->currency;
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
/**
|
| 163 |
-
* Return the Transaction Host Address
|
| 164 |
-
*
|
| 165 |
-
* @param $host
|
| 166 |
-
* @return $this
|
| 167 |
-
*/
|
| 168 |
-
public function setTransactionHost($host)
|
| 169 |
-
{
|
| 170 |
-
$this->host = $host;
|
| 171 |
-
return $this;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/**
|
| 175 |
-
* Returns the Transaction Host
|
| 176 |
-
*
|
| 177 |
-
* @return string
|
| 178 |
-
*/
|
| 179 |
-
public function getTransactionHost()
|
| 180 |
-
{
|
| 181 |
-
return $this->host;
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
/**
|
| 185 |
-
* Returns the Google Paket for Transaction Tracking
|
| 186 |
-
*
|
| 187 |
-
* @return array
|
| 188 |
-
* @throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
| 189 |
-
*/
|
| 190 |
-
public function getPaket()
|
| 191 |
-
{
|
| 192 |
-
if( !$this->getID() )
|
| 193 |
-
{
|
| 194 |
-
throw new MissingTrackingParameterException('transaction id is missing');
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
return array(
|
| 198 |
-
't' => 'transaction',
|
| 199 |
-
'ti' => $this->getID(),
|
| 200 |
-
'ta' => $this->getAffiliation(),
|
| 201 |
-
'tr' => $this->getRevenue(),
|
| 202 |
-
'ts' => $this->getShipping(),
|
| 203 |
-
'tt' => $this->getTax(),
|
| 204 |
-
'dh' => $this->getTransactionHost(),
|
| 205 |
-
'cu' => $this->getCurrency()
|
| 206 |
-
);
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ception\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 Event extends AbstractTracking
|
| 23 |
-
{
|
| 24 |
-
/** @var String */
|
| 25 |
-
private $eventCategory;
|
| 26 |
-
|
| 27 |
-
/** @var String */
|
| 28 |
-
private $eventAction;
|
| 29 |
-
|
| 30 |
-
/** @var String */
|
| 31 |
-
private $eventLabel;
|
| 32 |
-
|
| 33 |
-
/** @var String */
|
| 34 |
-
private $eventValue;
|
| 35 |
-
|
| 36 |
-
/**
|
| 37 |
-
* Set the Event Action (Required)
|
| 38 |
-
*
|
| 39 |
-
* @param $eventAction
|
| 40 |
-
* @return $this
|
| 41 |
-
*/
|
| 42 |
-
public function setEventAction($eventAction)
|
| 43 |
-
{
|
| 44 |
-
$this->eventAction = $eventAction;
|
| 45 |
-
return $this;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
/**
|
| 49 |
-
* Get the Event Action
|
| 50 |
-
*
|
| 51 |
-
* @return $this
|
| 52 |
-
*/
|
| 53 |
-
public function getEventAction()
|
| 54 |
-
{
|
| 55 |
-
return $this->eventAction;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
/**
|
| 59 |
-
* Set the Event Category (Required)
|
| 60 |
-
*
|
| 61 |
-
* @param $eventCategory
|
| 62 |
-
* @return $this
|
| 63 |
-
*/
|
| 64 |
-
public function setEventCategory($eventCategory)
|
| 65 |
-
{
|
| 66 |
-
$this->eventCategory = $eventCategory;
|
| 67 |
-
return $this;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
/**
|
| 71 |
-
* Get the Event Category
|
| 72 |
-
*
|
| 73 |
-
* @return $this
|
| 74 |
-
*/
|
| 75 |
-
public function getEventCategory()
|
| 76 |
-
{
|
| 77 |
-
return $this->eventCategory;
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
/**
|
| 81 |
-
* Set the Event Label
|
| 82 |
-
*
|
| 83 |
-
* @param $eventLabel
|
| 84 |
-
* @return $this
|
| 85 |
-
*/
|
| 86 |
-
public function setEventLabel($eventLabel)
|
| 87 |
-
{
|
| 88 |
-
$this->eventLabel = $eventLabel;
|
| 89 |
-
return $this;
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
/**
|
| 93 |
-
* Get the Event Label
|
| 94 |
-
*
|
| 95 |
-
* @return $this
|
| 96 |
-
*/
|
| 97 |
-
public function getEventLabel()
|
| 98 |
-
{
|
| 99 |
-
return $this->eventLabel;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
* Set the Event Value
|
| 104 |
-
*
|
| 105 |
-
* @param $eventValue
|
| 106 |
-
* @return $this
|
| 107 |
-
*/
|
| 108 |
-
public function setEventValue($eventValue)
|
| 109 |
-
{
|
| 110 |
-
$this->eventValue = $eventValue;
|
| 111 |
-
return $this;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
/**
|
| 115 |
-
* Get the Event Value
|
| 116 |
-
*
|
| 117 |
-
* @return $this
|
| 118 |
-
*/
|
| 119 |
-
public function getEventValue()
|
| 120 |
-
{
|
| 121 |
-
return $this->eventValue;
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
/**
|
| 125 |
-
* Returns the Paket for Event Tracking
|
| 126 |
-
*
|
| 127 |
-
* @return array
|
| 128 |
-
* @throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
| 129 |
-
*/
|
| 130 |
-
public function getPaket()
|
| 131 |
-
{
|
| 132 |
-
if (!$this->getEventCategory()) {
|
| 133 |
-
throw new MissingTrackingParameterException('event category musst be set');
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
if (!$this->getEventAction()) {
|
| 137 |
-
throw new MissingTrackingParameterException('event action musst be set');
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
return array(
|
| 141 |
-
't' => 'event',
|
| 142 |
-
'ec' => $this->getEventCategory(),
|
| 143 |
-
'ea' => $this->getEventAction(),
|
| 144 |
-
'el' => $this->getEventLabel(),
|
| 145 |
-
'ev' => $this->getEventValue()
|
| 146 |
-
);
|
| 147 |
-
}
|
| 148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/Exception.php
DELETED
|
@@ -1,85 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking;
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Google Analytics Measurement PHP Class
|
| 6 |
-
* Licensed under the 3-clause BSD License.
|
| 7 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 8 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 9 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 10 |
-
*
|
| 11 |
-
* Google Documentation
|
| 12 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 13 |
-
*
|
| 14 |
-
* @author Marco Rieger
|
| 15 |
-
* @email Rieger(at)racecore.de
|
| 16 |
-
* @git https://github.com/ins0
|
| 17 |
-
* @url http://www.racecore.de
|
| 18 |
-
* @package Racecore\GATracking\Tracking
|
| 19 |
-
*/
|
| 20 |
-
class Exception extends AbstractTracking
|
| 21 |
-
{
|
| 22 |
-
/** @var string */
|
| 23 |
-
private $exceptionDescription;
|
| 24 |
-
|
| 25 |
-
/** @var bool */
|
| 26 |
-
private $exceptionFatal;
|
| 27 |
-
|
| 28 |
-
/**
|
| 29 |
-
* Set the Exception Description
|
| 30 |
-
*
|
| 31 |
-
* @param $exceptionDescription
|
| 32 |
-
* @return $this
|
| 33 |
-
*/
|
| 34 |
-
public function setExceptionDescription($exceptionDescription)
|
| 35 |
-
{
|
| 36 |
-
$this->exceptionDescription = $exceptionDescription;
|
| 37 |
-
return $this;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
/**
|
| 41 |
-
* Get the Exception Description
|
| 42 |
-
*
|
| 43 |
-
* @return String
|
| 44 |
-
*/
|
| 45 |
-
public function getExceptionDescription()
|
| 46 |
-
{
|
| 47 |
-
return $this->exceptionDescription;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
/**
|
| 51 |
-
* Set if Exception is fatal
|
| 52 |
-
*
|
| 53 |
-
* @param $exceptionFatal
|
| 54 |
-
* @return $this
|
| 55 |
-
*/
|
| 56 |
-
public function setExceptionFatal($exceptionFatal)
|
| 57 |
-
{
|
| 58 |
-
$this->exceptionFatal = (bool) $exceptionFatal;
|
| 59 |
-
return $this;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
/**
|
| 63 |
-
* Get Exception is fatal
|
| 64 |
-
*
|
| 65 |
-
* @return bool
|
| 66 |
-
*/
|
| 67 |
-
public function getExceptionFatal()
|
| 68 |
-
{
|
| 69 |
-
return $this->exceptionFatal;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
/**
|
| 73 |
-
* Returns the Paket for Exception Tracking
|
| 74 |
-
*
|
| 75 |
-
* @return array
|
| 76 |
-
*/
|
| 77 |
-
public function getPaket()
|
| 78 |
-
{
|
| 79 |
-
return array(
|
| 80 |
-
't' => 'exception',
|
| 81 |
-
'exd' => $this->getExceptionDescription(),
|
| 82 |
-
'exf' => ( $this->getExceptionFatal() ? '1' : '0' )
|
| 83 |
-
);
|
| 84 |
-
}
|
| 85 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/Page.php
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking;
|
| 3 |
-
|
| 4 |
-
/**
|
| 5 |
-
* Google Analytics Measurement PHP Class
|
| 6 |
-
* Licensed under the 3-clause BSD License.
|
| 7 |
-
* This source file is subject to the 3-clause BSD License that is
|
| 8 |
-
* bundled with this package in the LICENSE file. It is also available at
|
| 9 |
-
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
|
| 10 |
-
*
|
| 11 |
-
* Google Documentation
|
| 12 |
-
* https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
| 13 |
-
*
|
| 14 |
-
* @author Marco Rieger
|
| 15 |
-
* @email Rieger(at)racecore.de
|
| 16 |
-
* @git https://github.com/ins0
|
| 17 |
-
* @url http://www.racecore.de
|
| 18 |
-
* @package Racecore\GATracking\Tracking
|
| 19 |
-
*/
|
| 20 |
-
class Page extends AbstractTracking
|
| 21 |
-
{
|
| 22 |
-
|
| 23 |
-
private $documentPath = '';
|
| 24 |
-
private $host = '';
|
| 25 |
-
private $title = '';
|
| 26 |
-
|
| 27 |
-
/**
|
| 28 |
-
* Set the Request Document Path
|
| 29 |
-
*
|
| 30 |
-
* @param $path
|
| 31 |
-
*/
|
| 32 |
-
public function setDocumentPath($path)
|
| 33 |
-
{
|
| 34 |
-
|
| 35 |
-
$this->documentPath = $path;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
/**
|
| 39 |
-
* Returns the Request Document Path
|
| 40 |
-
*
|
| 41 |
-
* @return string
|
| 42 |
-
*/
|
| 43 |
-
public function getDocumentPath()
|
| 44 |
-
{
|
| 45 |
-
|
| 46 |
-
if (!$this->documentPath) {
|
| 47 |
-
return '/';
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
return $this->documentPath;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
/**
|
| 54 |
-
* Sets the Document Title in Analytics Report
|
| 55 |
-
*
|
| 56 |
-
* @param $title
|
| 57 |
-
*/
|
| 58 |
-
public function setDocumentTitle($title)
|
| 59 |
-
{
|
| 60 |
-
|
| 61 |
-
$this->title = $title;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
/**
|
| 65 |
-
* Return Document Title
|
| 66 |
-
*
|
| 67 |
-
* @return string
|
| 68 |
-
*/
|
| 69 |
-
public function getDocumentTitle()
|
| 70 |
-
{
|
| 71 |
-
|
| 72 |
-
return $this->title;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
/**
|
| 76 |
-
* Return the Document Host Adress
|
| 77 |
-
*
|
| 78 |
-
* @param $host
|
| 79 |
-
* @return $this
|
| 80 |
-
*/
|
| 81 |
-
public function setDocumentHost($host)
|
| 82 |
-
{
|
| 83 |
-
$this->host = $host;
|
| 84 |
-
return $this;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
/**
|
| 88 |
-
* Return Document Host
|
| 89 |
-
*
|
| 90 |
-
* @return string
|
| 91 |
-
*/
|
| 92 |
-
public function getDocumentHost()
|
| 93 |
-
{
|
| 94 |
-
return $this->host;
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
/**
|
| 98 |
-
* Returns the Google Paket for Campaign Tracking
|
| 99 |
-
*
|
| 100 |
-
* @return array
|
| 101 |
-
*/
|
| 102 |
-
public function getPaket()
|
| 103 |
-
{
|
| 104 |
-
return array(
|
| 105 |
-
't' => 'pageview',
|
| 106 |
-
'dh' => $this->getDocumentHost(),
|
| 107 |
-
'dp' => $this->getDocumentPath(),
|
| 108 |
-
'dt' => $this->getDocumentTitle()
|
| 109 |
-
);
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/Social.php
DELETED
|
@@ -1,125 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking;
|
| 3 |
-
use Racecore\GATracking\Exception\MissingTrackingParameterException;
|
| 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 Social extends AbstractTracking
|
| 22 |
-
{
|
| 23 |
-
/** @var String */
|
| 24 |
-
private $socialAction;
|
| 25 |
-
|
| 26 |
-
/** @var String */
|
| 27 |
-
private $socialNetwork;
|
| 28 |
-
|
| 29 |
-
/** @var String */
|
| 30 |
-
private $socialTarget;
|
| 31 |
-
|
| 32 |
-
/**
|
| 33 |
-
* Set the Social Action (Required)
|
| 34 |
-
*
|
| 35 |
-
* @param $socialAction
|
| 36 |
-
* @return $this
|
| 37 |
-
*/
|
| 38 |
-
public function setSocialAction($socialAction)
|
| 39 |
-
{
|
| 40 |
-
$this->socialAction = $socialAction;
|
| 41 |
-
return $this;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
/**
|
| 45 |
-
* Get the Social Action
|
| 46 |
-
*
|
| 47 |
-
* @return String
|
| 48 |
-
*/
|
| 49 |
-
public function getSocialAction()
|
| 50 |
-
{
|
| 51 |
-
return $this->socialAction;
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
/**
|
| 55 |
-
* Set the Social Network (Required)
|
| 56 |
-
*
|
| 57 |
-
* @param $socialNetwork
|
| 58 |
-
* @return $this
|
| 59 |
-
*/
|
| 60 |
-
public function setSocialNetwork($socialNetwork)
|
| 61 |
-
{
|
| 62 |
-
$this->socialNetwork = $socialNetwork;
|
| 63 |
-
return $this;
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
/**
|
| 67 |
-
* Get the Social Network
|
| 68 |
-
*
|
| 69 |
-
* @return String
|
| 70 |
-
*/
|
| 71 |
-
public function getSocialNetwork()
|
| 72 |
-
{
|
| 73 |
-
return $this->socialNetwork;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
/**
|
| 77 |
-
* Set the Social Target (Required)
|
| 78 |
-
*
|
| 79 |
-
* @param $socialTarget
|
| 80 |
-
* @return $this
|
| 81 |
-
*/
|
| 82 |
-
public function setSocialTarget($socialTarget)
|
| 83 |
-
{
|
| 84 |
-
$this->socialTarget = $socialTarget;
|
| 85 |
-
return $this;
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
/**
|
| 89 |
-
* Get the Social Target
|
| 90 |
-
*
|
| 91 |
-
* @return String
|
| 92 |
-
*/
|
| 93 |
-
public function getSocialTarget()
|
| 94 |
-
{
|
| 95 |
-
return $this->socialTarget;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
/**
|
| 99 |
-
* Returns the Google Paket for Social Tracking
|
| 100 |
-
*
|
| 101 |
-
* @return array
|
| 102 |
-
* @throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
| 103 |
-
*/
|
| 104 |
-
public function getPaket()
|
| 105 |
-
{
|
| 106 |
-
if (!$this->getSocialAction()) {
|
| 107 |
-
throw new MissingTrackingParameterException('social action musst be set');
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
if (!$this->getSocialNetwork()) {
|
| 111 |
-
throw new MissingTrackingParameterException('social network musst be set');
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
if (!$this->getSocialTarget()) {
|
| 115 |
-
throw new MissingTrackingParameterException('social target musst be set');
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
return array(
|
| 119 |
-
't' => 'social',
|
| 120 |
-
'sa' => $this->getSocialAction(),
|
| 121 |
-
'sn' => $this->getSocialNetwork(),
|
| 122 |
-
'st' => $this->getSocialTarget()
|
| 123 |
-
);
|
| 124 |
-
}
|
| 125 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/includes/ga-mp/src/Racecore/GATracking/Tracking/User/Timing.php
DELETED
|
@@ -1,250 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
namespace Racecore\GATracking\Tracking\User;
|
| 3 |
-
|
| 4 |
-
use Racecore\GATracking\Tracking\AbstractTracking;
|
| 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\User
|
| 21 |
-
*/
|
| 22 |
-
class Timing extends AbstractTracking
|
| 23 |
-
{
|
| 24 |
-
/** @var string */
|
| 25 |
-
private $timingCategory;
|
| 26 |
-
|
| 27 |
-
/** @var string */
|
| 28 |
-
private $timingVariable;
|
| 29 |
-
|
| 30 |
-
/** @var integer */
|
| 31 |
-
private $timingTime;
|
| 32 |
-
|
| 33 |
-
/** @var string */
|
| 34 |
-
private $timingLabel;
|
| 35 |
-
|
| 36 |
-
/** @var integer */
|
| 37 |
-
private $browserDnsLoadTime;
|
| 38 |
-
|
| 39 |
-
/** @var integer */
|
| 40 |
-
private $browserPageDownloadTime;
|
| 41 |
-
|
| 42 |
-
/** @var integer */
|
| 43 |
-
private $browserRedirectTime;
|
| 44 |
-
|
| 45 |
-
/** @var integer */
|
| 46 |
-
private $browserTcpConnectTime;
|
| 47 |
-
|
| 48 |
-
/** @var integer */
|
| 49 |
-
private $browserServerResponseTime;
|
| 50 |
-
|
| 51 |
-
/**
|
| 52 |
-
* Set the browser dns load time
|
| 53 |
-
*
|
| 54 |
-
* @param int $browserDnsLoadTime
|
| 55 |
-
*/
|
| 56 |
-
public function setBrowserDnsLoadTime($browserDnsLoadTime)
|
| 57 |
-
{
|
| 58 |
-
$this->browserDnsLoadTime = $browserDnsLoadTime;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/**
|
| 62 |
-
* Get the browser dns load time
|
| 63 |
-
*
|
| 64 |
-
* @return int
|
| 65 |
-
*/
|
| 66 |
-
public function getBrowserDnsLoadTime()
|
| 67 |
-
{
|
| 68 |
-
return $this->browserDnsLoadTime;
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
/**
|
| 72 |
-
* Set the browser page download time
|
| 73 |
-
*
|
| 74 |
-
* @param int $browserPageDownloadTime
|
| 75 |
-
*/
|
| 76 |
-
public function setBrowserPageDownloadTime($browserPageDownloadTime)
|
| 77 |
-
{
|
| 78 |
-
$this->browserPageDownloadTime = $browserPageDownloadTime;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
/**
|
| 82 |
-
* Get the browser page download time
|
| 83 |
-
* @return int
|
| 84 |
-
*/
|
| 85 |
-
public function getBrowserPageDownloadTime()
|
| 86 |
-
{
|
| 87 |
-
return $this->browserPageDownloadTime;
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
/**
|
| 91 |
-
* Set the browser redirect time
|
| 92 |
-
*
|
| 93 |
-
* @param int $browserRedirectTime
|
| 94 |
-
*/
|
| 95 |
-
public function setBrowserRedirectTime($browserRedirectTime)
|
| 96 |
-
{
|
| 97 |
-
$this->browserRedirectTime = $browserRedirectTime;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
/**
|
| 101 |
-
* Get the browser redirect time
|
| 102 |
-
*
|
| 103 |
-
* @return int
|
| 104 |
-
*/
|
| 105 |
-
public function getBrowserRedirectTime()
|
| 106 |
-
{
|
| 107 |
-
return $this->browserRedirectTime;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/**
|
| 111 |
-
* Set the browser server response time
|
| 112 |
-
*
|
| 113 |
-
* @param int $browserServerResponseTime
|
| 114 |
-
*/
|
| 115 |
-
public function setBrowserServerResponseTime($browserServerResponseTime)
|
| 116 |
-
{
|
| 117 |
-
$this->browserServerResponseTime = $browserServerResponseTime;
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
/**
|
| 121 |
-
* Get the browser server response time
|
| 122 |
-
*
|
| 123 |
-
* @return int
|
| 124 |
-
*/
|
| 125 |
-
public function getBrowserServerResponseTime()
|
| 126 |
-
{
|
| 127 |
-
return $this->browserServerResponseTime;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
/**
|
| 131 |
-
* Set the browser tcp conenct time
|
| 132 |
-
*
|
| 133 |
-
* @param int $browserTcpConnectTime
|
| 134 |
-
*/
|
| 135 |
-
public function setBrowserTcpConnectTime($browserTcpConnectTime)
|
| 136 |
-
{
|
| 137 |
-
$this->browserTcpConnectTime = $browserTcpConnectTime;
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
/**
|
| 141 |
-
* Get the browser tcp conenct time
|
| 142 |
-
*
|
| 143 |
-
* @return int
|
| 144 |
-
*/
|
| 145 |
-
public function getBrowserTcpConnectTime()
|
| 146 |
-
{
|
| 147 |
-
return $this->browserTcpConnectTime;
|
| 148 |
-
}
|
| 149 |
-
|
| 150 |
-
/**
|
| 151 |
-
* Set the timing category
|
| 152 |
-
*
|
| 153 |
-
* @param string $timingCategory
|
| 154 |
-
*/
|
| 155 |
-
public function setTimingCategory($timingCategory)
|
| 156 |
-
{
|
| 157 |
-
$this->timingCategory = $timingCategory;
|
| 158 |
-
}
|
| 159 |
-
|
| 160 |
-
/**
|
| 161 |
-
* Get the timing category
|
| 162 |
-
*
|
| 163 |
-
* @return string
|
| 164 |
-
*/
|
| 165 |
-
public function getTimingCategory()
|
| 166 |
-
{
|
| 167 |
-
return $this->timingCategory;
|
| 168 |
-
}
|
| 169 |
-
|
| 170 |
-
/**
|
| 171 |
-
* Set the timing label
|
| 172 |
-
*
|
| 173 |
-
* @param string $timingLabel
|
| 174 |
-
*/
|
| 175 |
-
public function setTimingLabel($timingLabel)
|
| 176 |
-
{
|
| 177 |
-
$this->timingLabel = $timingLabel;
|
| 178 |
-
}
|
| 179 |
-
|
| 180 |
-
/**
|
| 181 |
-
* Get the timing label
|
| 182 |
-
*
|
| 183 |
-
* @return string
|
| 184 |
-
*/
|
| 185 |
-
public function getTimingLabel()
|
| 186 |
-
{
|
| 187 |
-
return $this->timingLabel;
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
/**
|
| 191 |
-
* Set the timing time
|
| 192 |
-
*
|
| 193 |
-
* @param int $timingTime
|
| 194 |
-
*/
|
| 195 |
-
public function setTimingTime($timingTime)
|
| 196 |
-
{
|
| 197 |
-
$this->timingTime = $timingTime;
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
/**
|
| 201 |
-
* Get the timing time
|
| 202 |
-
*
|
| 203 |
-
* @return int
|
| 204 |
-
*/
|
| 205 |
-
public function getTimingTime()
|
| 206 |
-
{
|
| 207 |
-
return $this->timingTime;
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
/**
|
| 211 |
-
* Set the timing variable
|
| 212 |
-
*
|
| 213 |
-
* @param string $timingVariable
|
| 214 |
-
*/
|
| 215 |
-
public function setTimingVariable($timingVariable)
|
| 216 |
-
{
|
| 217 |
-
$this->timingVariable = $timingVariable;
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
-
/**
|
| 221 |
-
* Get the timing time
|
| 222 |
-
*
|
| 223 |
-
* @return string
|
| 224 |
-
*/
|
| 225 |
-
public function getTimingVariable()
|
| 226 |
-
{
|
| 227 |
-
return $this->timingVariable;
|
| 228 |
-
}
|
| 229 |
-
|
| 230 |
-
/**
|
| 231 |
-
* Returns the Paket for User Timing Tracking
|
| 232 |
-
*
|
| 233 |
-
* @return array
|
| 234 |
-
*/
|
| 235 |
-
public function getPaket()
|
| 236 |
-
{
|
| 237 |
-
return array(
|
| 238 |
-
't' => 'timing',
|
| 239 |
-
'utc' => $this->getTimingCategory(),
|
| 240 |
-
'utv' => $this->getTimingVariable(),
|
| 241 |
-
'utt' => $this->getTimingTime(),
|
| 242 |
-
'utl' => $this->getTimingLabel(),
|
| 243 |
-
'dns' => $this->getBrowserDnsLoadTime(),
|
| 244 |
-
'pdt' => $this->getBrowserPageDownloadTime(),
|
| 245 |
-
'rrt' => $this->getBrowserRedirectTime(),
|
| 246 |
-
'tcp' => $this->getBrowserTcpConnectTime(),
|
| 247 |
-
'srt' => $this->getBrowserServerResponseTime()
|
| 248 |
-
);
|
| 249 |
-
}
|
| 250 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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