Skip to main content
To install CrispStats on WordPress, print the script tag in <head> with a wp_head action. You can add the action to your theme’s functions.php or to a small site plugin. Both load the same tag on every page WordPress renders, with no WordPress plugin from CrispStats needed.

Add the script

1

Copy the WordPress snippet

In the dashboard, open your site’s Settings, select Tracking code and choose the WordPress tab. It has your public key filled in:
functions.php
2

Add it to your site

Choose one place for the code.
A site plugin keeps the tag when you switch or update your theme. Create the file wp-content/plugins/crispstats/crispstats.php:
wp-content/plugins/crispstats/crispstats.php
Then open Plugins in the WordPress admin and activate CrispStats.
3

Clear caches and open your site

If you use a page cache, clear it so visitors get pages with the tag. Then open your live site while signed out, or in a private window. The status row on the Tracking code tab shows Receiving events. once the first event has been stored.

Add optional modules

The switches under Extra events on the Tracking code tab add attributes to the tag in the WordPress snippet. With outbound links, downloads and web vitals on, it looks like this:
functions.php
To keep your own visits out of the numbers, set localStorage.crispstats_ignore in your browser, or add data-exclude for paths you do not want tracked. See exclude traffic.
Keep the tag a classic script with defer or async. If an optimization plugin changes it to type="module", the script cannot read its options and does not track.

Check that it works

  • Open your site while signed out, or in a private window, with the browser’s developer tools on the Network tab. You should see d.js load from in.crispstats.com and a POST to https://in.crispstats.com/e that gets 202.
  • Open the page source and search for in.crispstats.com/d.js. If it is missing, the page cache still serves an old copy, or the theme does not call wp_head().
  • Open https://in.crispstats.com/check?k=cs_pk_xxxxxxxx with your key. "site": "known" means the key is right. The visit appears in Realtime within seconds.
If an optimization plugin combines, delays or rewrites scripts, exclude in.crispstats.com/d.js from it. The tag has to stay a classic script with its data- attributes intact.

How page changes are counted

A WordPress site does a full page load per page, so the script counts one pageview per page. The admin area does not get the tag: wp_head runs for the pages your theme renders, not for /wp-admin. If a theme or plugin changes pages without a reload and updates the URL through the History API, the script counts each new URL too.

Send custom events

  • Clicks on a button or link: in the block editor, edit the block as HTML (or use a Custom HTML block) and add data-cs-event:
  • Form submissions: send the form to a thank-you page and add a goal with a Page visit rule for that path.
  • From PHP: actions that happen on the server, such as an order in a webhook, can be sent as server-side events with a secret key. Never print that key in a page.

FAQ

No. The wp_head action, in your theme or a small site plugin of your own, is the whole install.
Visits to /wp-admin are not tracked, because the tag is not there. Your visits to the public site are counted unless you exclude your browser with localStorage.crispstats_ignore. See exclude traffic.
There is no WooCommerce integration. Report orders from your server with the payment API, with the visitor id you saved at checkout.

Next steps

Exclude traffic

Leave out your own browser and private paths.

Script attributes

Every option the script tag accepts.

Track custom events

Send form submissions and other actions.
Last modified on November 23, 2026