How to Add Analytics to WordPress Without Cookies or Plugins

WordPress powers over 40% of the web. Most WordPress sites use Google Analytics, which means most WordPress sites need a cookie consent banner.

There's a simpler way. Here's how to add privacy-friendly analytics to any WordPress site — without a plugin, without cookies, and without a consent banner.

Option 1: Add via functions.php (recommended)

Open your theme's functions.php file (or your child theme's) and add this:

function fairlytics_tracking_script() {
    echo '<script src="https://app.fairlytics.dev/js/tracker.v1.js" data-site="YOUR_SITE_ID" data-api="https://app.fairlytics.dev"></script>';
}
add_action('wp_footer', 'fairlytics_tracking_script');

This hooks into WordPress's footer and adds the tracking script to every page. It's the cleanest approach because it survives theme updates (if you use a child theme).

Option 2: Add via theme header

If you prefer, go to Appearance → Theme Editor (or Theme File Editor in newer versions), open your theme's header.php or footer.php, and paste this before </body>:

<script
  src="https://app.fairlytics.dev/js/tracker.v1.js"
  data-site="YOUR_SITE_ID"
  data-api="https://app.fairlytics.dev"
></script>

Note: this approach may be overwritten when you update your theme.

Option 3: Use the "Insert Headers and Footers" plugin

If you're not comfortable editing PHP files, install a plugin like WPCode (formerly Insert Headers and Footers), and paste the script snippet into the "Footer" section. This is plugin-based, but at least it's not a bloated analytics plugin.

Why not use a Google Analytics plugin?

WordPress has dozens of GA plugins (MonsterInsights, Site Kit, etc.). They all do the same thing: load Google's ~82 KB tracking script, set cookies, and send your visitors' data to Google.

This means:

With Fairlytics, none of that applies. The script is 510 bytes, sets zero cookies, and never stores IP addresses. No consent banner required.

Works with every WordPress setup

What you get

Without cookies or personal data:

You get the metrics that matter without the privacy baggage. See how visitor counting works without cookies.

Remove your cookie banner

Once you switch from Google Analytics to Fairlytics, check if GA was the only reason you had a cookie consent banner. If you don't use any other cookie-setting services (ad networks, Facebook Pixel, etc.), you can safely remove the banner entirely.

Your WordPress site just got faster and cleaner.


Sign up for Fairlytics — free plan, no credit card. Get your site ID and add the script in under 2 minutes.