Skip to content
Ben Gillbanks edited this page Sep 20, 2019 · 7 revisions

Website statistics are very helpful things to use, but they are also a privacy nightmare.

When a service is free you are the product

Over the last year a handful of privacy focused analytics companies have appeared. They are all premium businesses. It costs money to run these things, and since they don't sell your data someone needs to pay the bills. Fortunately the cost for all of them are fair and they all seem to work well. So I've added support for all of them.

Stats Providers

Filters

toolbelt_stats_track

Should we track the current user? We can use this filter to enable or disable the stats under different conditions.

Don't track signed in users: Note: this isn't done by default since many sites use caching plugins in which case it won't work since the tracking status may get cached. If you use a caching plugin and don't want to track logged in users then make sure caching is disabled for logged in users.

function my_stats_track() {
    if ( is_user_logged_in() ) {
        return false;
    }
    return true;
}
add_filter( 'toolbelt_stats_track', 'my_stats_track' );

Don't track specific pages:

function my_stats_track() {
    if ( in_array( get_the_ID(), array( 56, 192, 201 ) ) {
        return false;
    }
    return true;
}
add_filter( 'toolbelt_stats_track', 'my_stats_track' );

Clone this wiki locally