Hello,
Google stopped passing an identifiable User-Agent string because of developers gaming the system in order to get better scores, thus impressing clients while their actual website was still slow.
Therefore we can no longer reliably remove Google Lighthouse hits from Koko Analytics, unless you include an easily detectable identifier in the URL yourself and write some code to instruct Koko Analytics to not record hits to this URL.
Here’s a sample snippet on how to disable tracking for certain URL’s: https://github.com/ibericode/koko-analytics/blob/master/code-snippets/disable-tracking-on-certain-urls.php
I hope that helps.
Danny
Thanks Danny,
If I cant catch Lighhouse user-agent, Can i Exclude Lighthouse IP ?? E.g : 66.249.xx.xx (Lighthouse IP)
Plugin Support
Lap
(@lapzor)
I used tthis…
// Disable Tracking by remote IP Address - Koko Analytic
add_filter( 'koko_analytics_load_tracking_script', function() {
$ip_address = $_SERVER['REMOTE_ADDR'];
$excluded_ip_addresses = array(
'127.0.0.1',
'114.79.0.0',
);
if (in_array($ip_address, $excluded_ip_addresses, true)) {
return false;
}
return true;
});
Unfortunately it does’t work with Cache Plugin. These snippet make script disapear..
Plugin Support
Lap
(@lapzor)
What caching do you use that you think is preventing this from working?
I recommend you also check if $_SERVER[‘REMOTE_ADDR’] is indeed returning the visitors IP, that depends on your server configuration.
It might be returning an array of IPs if there is some proxy in between. or it may not return anything.
// Disable Tracking by remote IP Address - Koko Analytic
add_filter( 'koko_analytics_load_tracking_script', function() {
$ip_address = $_SERVER['REMOTE_ADDR'];
echo "<!-- DEBUG: ". $_SERVER['REMOTE_ADDR']." -->";
$excluded_ip_addresses = array(
'127.0.0.1',
'114.79.0.0',
);
if (in_array($ip_address, $excluded_ip_addresses, false)) {
return false;
}
return true;
});