Before you start
Create a free Cool Analytics account and add your site. You'll get a site ID — replace YOUR_SITE_ID in the code below with it. The dashboard shows the snippet with your ID already filled in.
Install on WordPress
- 1In your WordPress admin, go to Plugins → Add New and install the free WPCode plugin (any header & footer code plugin works).
- 2Go to Code Snippets → Header & Footer.
- 3Paste the snippet into the Header box and click Save Changes.
<script defer src="https://coolanalytics.dev/hb.js" data-site="YOUR_SITE_ID"></script>
Check that it works
Open your live site in a new tab, then open your Cool Analytics dashboard. Your visit appears on the live map within seconds — with the page you're on, where you came from and your browser.
Nothing showing up? Make sure you're looking at the published site (not a preview or editor), that an ad blocker isn't blocking the script, and that you're not testing on localhost.
Track signups, purchases and clicks
Pageviews, sources, countries and outbound link clicks are tracked automatically. For the moments that matter to you, send a custom event. Events named like a signup show up as signups, and events with an amount show up as revenue — on the live map and per traffic source.
// anywhere in your WordPress site's browser code
window.hb?.track("signup");
// with an amount, it shows up as revenue
window.hb?.track("purchase", { amount: 49 });WordPress tips
- No-plugin option: in a child theme's functions.php, add a function hooked to wp_head that echoes the snippet. Don't edit a parent theme directly — updates will overwrite it.
- Logged-in admins browsing the site are counted too. Visit your site once with #hb-ignore at the end of the URL to exclude your own browser.
- Caching plugins (WP Rocket, LiteSpeed, etc.) are fine. If they offer to “delay JavaScript”, exclude hb.js so visitors who leave quickly are still counted.
Want to keep your own visits out of the stats? Open your site once with #hb-ignore at the end of the URL. That browser is excluded until you visit with #hb-track.
WordPress analytics FAQ
Can I replace Google Analytics on WordPress with this?+
Yes. Remove the GA plugin or tag, add this snippet, and you no longer need a cookie banner for analytics.
Does it work on WordPress.com?+
Adding custom scripts on WordPress.com requires a plan that allows plugins (Business or higher). Self-hosted WordPress works on any host.
Does it work with block themes and Elementor?+
Yes. The plugin injects the script through wp_head, which every theme and page builder outputs.