Skip to main content

WordPress

WordPress sites can install PureStats through a theme file, a header/footer injection plugin or a custom site plugin.

Header injection plugin

The simplest option is a reputable header injection plugin:

  1. Install a plugin that can add scripts to the site header.
  2. Paste the PureStats script.
  3. Save and clear page caches.
  4. Open the public site and verify the first hit.
<script defer src="https://purestats.io/pf.js" data-domain="example.com"></script>

Theme template

If you control the theme, place the script in header.php before wp_head() or immediately after it. Prefer a child theme so future theme updates do not overwrite the change.

<script defer src="https://purestats.io/pf.js" data-domain="example.com"></script>
<?php wp_head(); ?>

Custom plugin

For teams with deployment workflows, create a tiny plugin that hooks into wp_head:

add_action('wp_head', function () {
echo '<script defer src="https://purestats.io/pf.js" data-domain="example.com"></script>';
});

Cache and optimization plugins

After installing, clear all caches. If an optimization plugin combines or delays scripts, exclude https://purestats.io/pf.js from aggressive rewriting until tracking is verified.

Private pages

PureStats normally tracks public pages only because the script is placed in the public theme. If your setup injects it into private WordPress pages too, add /wp-admin/* to path exclusions.