Developer Docs

The Developer Docs for CAOS Pro contain a list of available filters and actions for WordPress developers to add and/or manipulate various functions.

Add the caos_pro_proxy_  filters to a must-use plugin: a PHP file in wp-content/mu-plugins/ . While Stealth Mode processes a hit, only CAOS and CAOS Pro are loaded, which keeps it fast.

caos_pro_proxy_user_ip_address

Manipulate the IP address before it’s sent to the Google Analytics API.

Since Google Analytics 4, (partially) masking the IP address will directly affect geolocation collection.

For example, to (partially) mask the IP address, you could add the following filter:

add_filter( 'caos_pro_proxy_user_ip_address', function ( $ip ) {
	$octets = explode( '.', $ip );

	// Leave IPv6 addresses untouched.
	if ( count( $octets ) !== 4 ) {
		return $ip;
	}

	// Mask the last octet. To mask the last two, add: $octets[2] = '0';
	$octets[3] = '0';

	return implode( '.', $octets );
} );
Code language: PHP (php)

caos_pro_proxy_excluded_user_agents

User-Agents whose hits aren’t sent to Google Analytics. By default, this includes bots, crawlers and cache warmers like NitroPack, WP Rocket and LiteSpeed Cache. Entries are matched case-insensitively, as part of a regular expression.

add_filter( 'caos_pro_proxy_excluded_user_agents', function ( $user_agents ) {
	$user_agents[] = 'my-uptime-monitor';

	return $user_agents;
} );
Code language: PHP (php)

caos_pro_proxy_excluded_hosts

Hosts of pages whose hits aren’t sent to Google Analytics, like cache warmers that render your pages on a local address. By default, this includes localhost , *.local , *.test , *.internal  and *.invalid , plus private IP addresses. A leading *.  matches any subdomain. Your own site’s host is always tracked.

add_filter( 'caos_pro_proxy_excluded_hosts', function ( $hosts ) {
	$hosts[] = '*.staging.example.com';

	return $hosts;
} );
Code language: PHP (php)

caos_pro_proxy_excluded_ips

IP addresses whose hits aren’t sent to Google Analytics, e.g. your own office (empty by default). Enter each IP address in full.

add_filter( 'caos_pro_proxy_excluded_ips', function ( $ips ) {
	return array_merge( $ips, [ '203.0.113.10' ] );
} );
Code language: PHP (php)

caos_pro_proxy_is_excluded_request

Decide for each hit whether it’s sent to Google Analytics: return true  to leave it out. Receives the current decision, the User-Agent, the IP address, the Sec-CH-UA client hint and the hit’s parameters (e.g. dl , the page location).

add_filter( 'caos_pro_proxy_is_excluded_request', function ( $excluded, $user_agent, $ip ) {
	return $excluded || strpos( $ip, '203.0.113.' ) === 0;
}, 10, 3 );
Code language: PHP (php)