Exclude pageviews from certain IP addresses
Koko Analytics comes with an easy setting that allows you to exclude pageviews from certain IP address or address ranges.

To configure the plugin to exclude visits from a certain IP address, navigate to the Koko Analytics > Settings page and locate the “Exclude pageviews from these IP addresses” setting.
In the textarea, you can enter a list of IP addresses to ignore. Enter each IP address on its own line. You can find your current IP addresses in the text below the textarea.
Exclude IP addresses through a filter hook
Alternatively, you can configure the setting above through a filter hook by hooking into the koko_analytics_load_tracking_script filter.
/**
* Plugin Name: Koko Analytics: Do not count visits from certain IP addresses
*/
add_filter( 'koko_analytics_load_tracking_script', function() {
$ip_address = $_SERVER['REMOTE_ADDR'];
$excluded_ip_addresses = array(
'127.0.0.1',
'254.123.182.1',
);
if (in_array($ip_address, $excluded_ip_addresses, true)) {
return false;
}
return true;
});
Code language: PHP (php)
Modify the snippet above to include your IP address and then save it as /wp-content/plugins/koko-analytics-exclude-ips.php. You can then activate it from your WP Admin > Plugins page.
More code snippets like this
For more code snippets like this that extend or modify the default behavior of the Koko Analytics plugin, please have a look at our repository of sample code snippets.