• Resolved arfanzr77

    (@arfanzr77)


    You have write some user agent to be ignored from script.js (/bot|crawl|spider|seo|lighthouse|preview/i). But when i check Google page speed insight it still increase the number of page views.

    Just note : I use WP Fastest Cache.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    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

    Thread Starter arfanzr77

    (@arfanzr77)

    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)

    You could adjust this code snippet to look for an IP instead of a UserAgent

    https://github.com/ibericode/koko-analytics/blob/master/code-snippets/ignore-tracking-for-certain-user-agents.php

    Thread Starter arfanzr77

    (@arfanzr77)

    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;
    });
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Lighthouse User Agent’ is closed to new replies.