Skip to Content

ga_send_exception()

Send a Google Analytics exception from the server side.

PHP June 11, 2017

Usage

PHP
nebula()->ga_send_exception($message, $fatal, $array)

Parameters

$message
(Required) (String) The error message
Default: None

$fatal
(Optional) (Boolean) If the error was fatal
Default: true

$array
(Optional) (Array) An array of additional custom values
Default: None

Parameter Notes

Be careful with the $message parameter that it doesn’t accidentally send personally identifiable information.

Refer to this documentation for parameters.

Request or provide clarification »

Source File

Located in /libs/Utilities/Analytics.php on line 233.

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_exception"
Need a new filter hook? Request one here.

Actions
This function has no action hooks available. Request one?

PHP
        public function ga_send_exception($message=null, $fatal=1, $array=array()){
            $override = apply_filters('pre_ga_send_exception', null, $message, $fatal, $array);
            if ( isset($override) ){return;}

            $data = array(
                't' => 'exception',
                'exd' => $message,
                'exf' => $fatal,
                'dt' => 'Page Not Found'
            );

            $data = array_merge($this->ga_common_parameters(), $data); //Add custom definition parameters
            $data = array_merge($data, $array); //Add passed parameters
            $this->ga_send_data($data, false); //Disabling force parameter here in an attempt to reduce or eliminate "(not set)" landing page data in Google Analytics.
        }

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_exception', 'my_custom_ga_send_exception', 10, 4); //The last integer must be 1 more than the actual parameters
function my_custom_ga_send_exception($null, $message, $fatal, $array){ //$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_exception', '__return_false');