Docs/WordPress

WordPress

Three ways to add the snippet, from the one that survives a theme change to the one that takes ten seconds.

The reliable way: a must-use plugin

A snippet pasted into a theme disappears the day the theme is changed or updated. A must-use plugin does not: create wp-content/mu-plugins/kipstats.php with this content — mu-plugins load on every request and cannot be deactivated by accident.

wp-content/mu-plugins/kipstats.php
<?php
/**
 * Plugin Name: Kipstats
 * Description: Cookie-free analytics. Survives theme changes.
 */
add_action('wp_head', function () {
    echo '<script defer src="https://kipstats.com/tracker.js" data-site="kp_xxxxxxxx"></script>';
}, 1);

In a child theme

If you already maintain a child theme, the same hook works from its functions.php:

functions.php
add_action('wp_head', function () {
    echo '<script defer src="https://kipstats.com/tracker.js" data-site="kp_xxxxxxxx"></script>';
}, 1);

With a header-script plugin

Plugins such as WPCode or "Insert Headers and Footers" have a header field: paste the one-line snippet there. Nothing else to configure.

<script defer src="https://kipstats.com/tracker.js" data-site="kp_xxxxxxxx"></script>

Caching plugins

The snippet is static HTML, so WP Rocket, LiteSpeed Cache and W3 Total Cache serve it happily. Two settings are worth checking: do not defer or delay third-party scripts in a way that drops the data-site attribute, and do not combine the file into a bundle — the tracker reads its own <script> tag to find your tracking ID, and a rewritten tag stops it working.

WooCommerce order confirmed by a payment gateway, subscription renewed by cron: those happen without a browser. Record them from PHP with the ingest key — see server-side events.

Check it works

  1. Open your site in a private window and view the page source.
  2. Search for tracker.js: the tag must carry your data-site="kp_…".
  3. Your visit appears in Live activity in the dashboard.