Usage
PHP
nebula()->ga_send_data($data)
Parameters
$data
(Required) (Array) An array of data
Default: None
Parameter Notes
Refer to this Google Analytics documentation for available parameters.
Source File
Located in /libs/Utilities/Analytics.php on line 366.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_ga_send_data"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
public function ga_send_data($data){
if ( $this->is_minimal_mode() ){return null;}
$override = apply_filters('pre_ga_send_data', null, $data);
if ( isset($override) ){return;}
//The GA Measurement Protocol requires a Measurement ID and an API Secret key
if ( $this->get_option('ga_api_secret') && $this->get_option('ga_measurement_id') ){
$response = wp_remote_post('https://www.google-analytics.com/mp/collect?measurement_id=' . $this->get_option('ga_measurement_id') . '&api_secret=' . $this->get_option('ga_api_secret'), array(
'body' => wp_json_encode($data),
'method' => 'POST',
));
return $response;
}
return null;
}
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
PHP
add_filter('pre_ga_send_data', 'my_custom_ga_send_data', 10, 2); //The last integer must be 1 more than the actual parameters
function my_custom_ga_send_data($null, $data){ //$null is required, but can be ignored
//Write your own code here
return true; //Return true to prevent the original function from running afterwords
}
You can completely disable this PHP function with a single line actions:
PHP
add_filter('pre_ga_send_data', '__return_false');