Functions and API

Creating Your First SlimStat Add-on

Applies to SlimStat 6.0.0 · checked

A SlimStat add-on is a WordPress plugin that registers supported hooks. Start with one small change and test it on staging before using it on a live site.

Create the plugin file

Create wp-content/plugins/my-slimstat-addon/my-slimstat-addon.php:

<?php
/**
 * Plugin Name: My SlimStat Add-on
 * Description: Labels tracked pageviews from a custom integration.
 * Version: 1.0.0
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
add_filter( 'slimstat_filter_pageview_stat', function ( $stat ) {
    if ( empty( $stat ) ) {
        return $stat;
    }
    $stat['notes'][] = 'custom integration';
    return $stat;
} );

Activate it under WordPress Plugins. Record a test visit and inspect its notes in the private Access Log. Remove the add-on if you no longer need that annotation.

Keep the tracking contract

Return the pageview array from the filter. Use existing fields and preserve consent restrictions; never restore an IP or identity that SlimStat intentionally withheld. The filter receives one array, not separate browser and page arguments.

Pageview filter reference · Custom reports

At this hook, notes is an array of strings. Append an entry; the tracker serializes the array before storage. Return an incoming empty array unchanged if another filter has already rejected the pageview.