Skip to Content
Menu

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 »

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

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

    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;}
    
                $event_parameters = array(
                    'message' => $message,
                    'fatal' => $fatal,
                    'page_title' => 'Page Not Found'
                );
    
                $data = array_merge($event_parameters, $array); //Add passed parameters
                $data = $this->ga_build_event('exception', $data);
                $this->ga_send_data($data);
            }
    

    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');