Skip to Content

is_analytics_allowed()

Check if analytics is allowed for this page rendering.

PHP July 24, 2018

Usage

PHP
nebula()->is_analytics_allowed()

Parameters

This function does not accept any parameters. Is this incorrect?

Additional Notes

This checks several conditions to determine if analytics should be enabled for this rendering.

Conditions that do not allow analytics:

  • If “Do Not Track” header is present and the Nebula option observe_dnt is set to comply with that request
  • If within the WordPress Customizer
  • If the query string noga is present
  • If the current IP address matches the server’s IP address itself

Source File

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

No Hooks

This function does not have any filters or actions available. Request one?
PHP
        public function is_analytics_allowed(){
            if ( $this->option('observe_dnt') && $this->is_do_not_track() ){
                return false;
            }

            if ( isset($_GET['noga']) || is_customize_preview() ){ //Disable analytics for ?noga query string
                return false;
            }

            if ( $this->get_ip_address() === wp_privacy_anonymize_ip($_SERVER['SERVER_ADDR']) ){ //Disable analytics for self-requests by the server
                return false;
            }

            return true;
        }

Override

This function can not be short-circuited with an override filter. Request one?