• Resolved essaund

    (@essaund)


    Does this plugin have a way to filter out your IP address when you’re not logged in on the website? I can’t see anywhere to filter out my IP.

    The process of doing it from Google Analytics is so depressing to follow.

    • This topic was modified 1 year, 7 months ago by essaund.
    • This topic was modified 1 year, 7 months ago by essaund.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Sure, you can use the caos_exclude_from_tracking filter. Something like:

    add_filter('caos_exclude_from_tracking', 'daan_exclude_ip_address');
    
    function daan_exclude_ip_address($exclude) {
        if (is_user_logged_in()) {
            return $exclude;
        }
    
        return isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === 'YOUR.IP.ADDRESS';
    }
    Thread Starter essaund

    (@essaund)

    Doesn’t seem to be working.

    Still tracks my IP when I’m logged out of the website. =(

    The function you’ve shared mentions if (is_user_logged_in( ) )

    Could that be the reason why it’s not working?

    • This reply was modified 1 year, 7 months ago by essaund.
    • This reply was modified 1 year, 7 months ago by essaund.
    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    You did replace YOUR.IP.ADDRESS with your IP address?

    Thread Starter essaund

    (@essaund)

    Yes, I did insert my IP there.

    Thread Starter essaund

    (@essaund)

    Just to be clear. It doesn’t track my IP when I’m logged in as an adminstrator. I have diabled this on the plugin. But once I log out of the website, it tracks my IP.

    I want to exclude my IP from tracking so that I can access the website from any device (attached to the same IP) without it being tracked.

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    I’ve tested it on my local environment. And it works.

    A few things to check:

    • If you’re running any page cache plugins, make sure you flush them.
    • Are you running the latest version of CAOS?
    • Your IP address is entered in between apostrophes, i.e. '192.168.178.0'?

    Thread Starter essaund

    (@essaund)

    Yes, I have updated CAOS and flushed all cache.
    Done everything as explained.

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Could you contact me using this form? Then I can share my IP address with you and I can do some further testing.

    No, actually, I think I know what be the cause. REMOTE_ADDR might contain multiple IP addresses. I’ll revise the code later today and get back to you.

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    Okay, so I felt like doing some fiddling, so I create a plugin that should be able to take care of this for you. You can download it from Github.

    It requires you to add your IP address using the caos_exclude_ips filter which is added by this plugin. So basically, you should add this in a custom plugin, or your (child) theme’s functions.php:

    add_filter('caos_exclude_ips', function () { return [ 'YOUR.IP.ADDRESS' ]; });

    This plugin checks several headers for the IP address, and also keeps in mind comma-separated strings. So, hopefully this’ll take care of it for you!

    Thread Starter essaund

    (@essaund)

    Sorry for the delayed response. My hands were full.

    I have installed the plugin and added the function as per your advice. Purged all cache. It’s still tracking my IP when logged out =(

    Thread Starter essaund

    (@essaund)

    And why can’t the IP filter be included in the CAOS plugin by default? I also use Independent Analytics and I love their integration. https://independentwp.com/knowledgebase/data/block-ip-addresses/

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    And why can’t the IP filter be included in the CAOS plugin by default?

    Because you’re the first to ever request this feature ?? I’ll think about adding it to core.

    It’s still tracking my IP when logged out

    Very strange. Have you double checked your IP using a site like https://www.whatsmyip.org/?

    I’ve updated the code in the Github repo and added a bit of debugger code. Can you update the code on your environment, run it by loading your frontend one time, and send me the debug information using this form?

    The caos-debug.log file will be located in your wp-content directory.

    Thread Starter essaund

    (@essaund)

    The updated version is causing a fatal error on PHP to occur.

    I’m also using a static IP address from my service provider.

    Plugin Author DaanvandenBergh

    (@daanvandenbergh)

    What’s the fatal error?

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How to Filter Internal Traffic (Your IP)’ is closed to new replies.