WordPress powers 43% of all websites, and most of them are either using Google Analytics (requiring a cookie banner) or have no analytics at all. Cookie-free analytics is the better middle path.
Option 1: Add the script directly to your theme
Edit your theme's footer.php and paste just before the closing </body> tag:
<script defer src="https://stats.yourdomain.com/t.php?site=YOUR_SITE_CODE"></script>
Option 2: Use a header/footer plugin
Install Insert Headers and Footers by WPBeginner. Go to Settings → Insert Headers and Footers, paste the tracking script in the Footer section, and save. Your tracking persists through theme changes.
Option 3: Add via functions.php
function add_analytics_script() {
echo '<script defer src="https://stats.yourdomain.com/t.php?site=YOUR_CODE"></script>';
}
add_action( 'wp_footer', 'add_analytics_script' );
Removing your cookie banner
With cookie-free analytics installed, deactivate and remove your cookie consent plugin. No cookies are set, so no consent is needed under GDPR or PECR. That's typically a 40–80KB page weight saving and a dramatically better first impression for new visitors.
Verifying the installation
Visit your WordPress site in a private/incognito window. In your analytics real-time tab, you should see your visit within 5 seconds. Use browser DevTools (Network tab, filter by "t.php") to confirm it returns HTTP 200.