/** * Load the PHP client in order to send hits to Google Analytics * via the measurement protocol. * * In order to send hits to Google Analytics from the server, we employ Google's * measurement protocol (https://developers.google.com/analytics/devguides/ * collection/protocol/v1/devguide). Rather than dealing with the raw library, * we use a lightweight PHP client from Racecore (https://github.com/ins0/google- * measurement-php-client) which we will refer to as ga-mp. */ function wpan_load_measurement_protocol_client() { define("WPAN_GAMP_DIR", WPAN_PLUGIN_DIR . 'vendor/ga-mp/src/'); define("WPAN_GAMP_URL", WPAN_PLUGIN_URL . 'vendor/ga-mp/src/'); $autoload_file = WPAN_GAMP_DIR . 'Racecore/GATracking/Autoloader.php'; if (file_exists($autoload_file)) { try { require_once $autoload_file; Racecore\GATracking\Autoloader::register(WPAN_GAMP_DIR); define("WPAN_GAMP_LOADED", true); wpan_log_debug("Measurement protocol client loaded."); return true; } catch (Exception $e) { wpan_log_debug("Could not load measurement protocol client; error message:"); wpan_log_debug($e->getMessage()); } } else { wpan_log_debug("Could not load measurement protocol client; file {$autoload_file} could not be found."); } }
/** * Load the google measurement protocol PHP client. * * @since 1.4.0 */ private function load_measurement_client() { require_once 'vendor/ga-mp/src/Racecore/GATracking/Autoloader.php'; Racecore\GATracking\Autoloader::register(dirname(__FILE__) . '/vendor/ga-mp/src/'); }
/** * Setup the google measurement protocol PHP client. * * @since 1.1.0 */ private function init_measurement_client() { require_once 'includes/ga-mp/src/Racecore/GATracking/Autoloader.php'; Racecore\GATracking\Autoloader::register(dirname(__FILE__) . '/includes/ga-mp/src/'); $this->ua_id = get_option('gravity_forms_event_tracking_ua'); if (!$this->ua_id) { return; } add_action('gform_after_submission', array($this, 'track_form'), 10, 2); }
<?php require_once dirname(__FILE__) . '/../src/Racecore/GATracking/Autoloader.php'; Racecore\GATracking\Autoloader::register(dirname(__FILE__) . '/../src/'); Racecore\GATracking\Autoloader::register(dirname(__FILE__) . '/../test/');