<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.
- Site plugin
- functions.php
A site plugin keeps the tag when you switch or update your theme. Create the file Then open Plugins in the WordPress admin and activate CrispStats.
wp-content/plugins/crispstats/crispstats.php:wp-content/plugins/crispstats/crispstats.php
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
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.jsload fromin.crispstats.comand aPOSTtohttps://in.crispstats.com/ethat gets202. - 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 callwp_head(). - Open
https://in.crispstats.com/check?k=cs_pk_xxxxxxxxwith your key."site": "known"means the key is right. The visit appears in Realtime within seconds.
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
Is there a CrispStats WordPress plugin?
Is there a CrispStats WordPress plugin?
No. The
wp_head action, in your theme or a small site plugin of your own, is the whole install.Will my own visits as an admin be counted?
Will my own visits as an admin be counted?
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.Can I record WooCommerce orders?
Can I record WooCommerce orders?
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.