koko-analytics
koko-analytics copied to clipboard
Feature suggestion: Exclude views by IP addresses
I am not sure if this feature might break the privacy following the plugin has, but it would be a super nice feature to include.
Personally, I would find this feature useful when I am testing something and I need to be logged off from my WordPress site to do it properly (normally, I just go into Incognito Mode, or a different device that I am not signed in).
Excluding by IP address is a good and standard way of doing this. What do you think?
Please vote on this feature suggestion using :+1: or :-1: below.
I fully support
While not supported from within the settings interface of the plugin just yet, after 132bd544e4d618cada65adf0b1904fe72f531842 you can now do this using a filter hook:
add_filter( 'koko_analytics_load_tracking_script', function() {
$ip_address = $_SERVER['REMOTE_ADDR'];
$excluded_ip_addresses = array(
'127.0.0.1',
'254.123.182.120',
);
if (in_array($ip_address, $excluded_ip_addresses, true)) {
return false;
}
return true;
});
Hello!
Tell me if this feature will be included in the plugin itself. If yes, then when?
Where should I indicate the code you provided?
Respectfully yours, Pavel
Hello @optimist-law,
I am not sure yet. I'd like to keep the settings relatively simple and avoid any settings that would only be used by less than 20% of the plugin's users.
Until then, you can place the code I shared in my previous comment in your theme its functions.php file or use the following and save it as /wp-content/plugins/enhance-koko-analytics.php
<?php
/**
* Plugin Name: Koko Analytics Enhancements
*/
add_filter( 'koko_analytics_load_tracking_script', function() {
$ip_address = $_SERVER['REMOTE_ADDR'];
$excluded_ip_addresses = array(
'127.0.0.1',
'254.123.182.120',
);
if (in_array($ip_address, $excluded_ip_addresses, true)) {
return false;
}
return true;
});
After doing that, go to WP Admin > Plugins and activate the Koko Analytics Enhancements plugin to activate the snippet.
Hello! Everything works perfectly. Thanks for the help! Respectfully yours, Pavel