Skip to content
Ben Gillbanks edited this page Aug 8, 2020 · 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.

If you don't want to spend any money, and your traffic isn't too high, then you could try Koko Analytics (for WordPress). It's self hosted so will use server resources, but it's also free.

Stats Providers

The following stats services are supported. Rather than pick one I have left it open so that you can evaluate and select the one that's most suitable for you. They are largely the same, but they all have slightly different features, and prices.

Personally I use Fathom. If you use this link to try Fathom you will save $10 off the first month (there's a free trial).

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' );