Install on WordPress
Install Statsy Analytics from the WordPress plugin directory, paste your website key, and optionally send WooCommerce orders as revenue.
The Statsy plugin adds the script to every public page, skips your own visits, and on WooCommerce sends paid orders and refunds to Statsy as revenue. It needs WordPress 6.0 and PHP 7.4 or newer.
Install the plugin
Install from the plugin directory
In WordPress go to Plugins › Add New, search for Statsy Analytics, then Install Now and Activate. It is also on WordPress.org, and updates arrive through the usual Plugins screen.
Paste your website key
Open Settings › Statsy and paste the key from Site settings › Tracking in Statsy. It starts with
ws_. Save.Check it works
Open your site in a private window and watch Live in Statsy. The visit appears within seconds. If you use a caching plugin or a CDN, purge the page cache once so cached pages pick up the tag.
Settings
| Setting | What it does |
|---|---|
| Do not track | Signed-in users with the roles you tick are never counted. Administrators and editors are ticked by default. |
| Cookies | Follow the site setting in Statsy, or force cookieless or first-party cookie mode for this site. |
| Capture automatically | Outbound links, downloads, form submissions, site search, video and uploads. WordPress search (?s=) is read with no setup. |
| Signed-in visitors | Off by default. When on, journeys show signed-in users by name, and optionally email, so payments can match by email. |
| Script host | Under Advanced. Set your first-party domain so ad blockers do not hide visits. |
WooCommerce revenue
With WooCommerce active, the plugin records a purchase goal on the order received page. For real revenue, create a site token under Site settings › API tokens and paste it into Revenue API token. From then on:
- At checkout the order remembers the buyer's Statsy visitor id.
- When the order is paid, your server sends it to the Payment API with that id, so the sale is credited to the channel, page and campaign that brought the buyer.
- Refunds are sent as refunds against the same customer. Renewals from WooCommerce Subscriptions are sent as renewals.
- Every call is idempotent on the order id, so a retry or a status change never counts a sale twice.
Note. Amounts are only ever sent from your server. The browser cannot report revenue, so nobody can inflate your numbers from the console.
For developers
Two filters cover most customisation:
// Skip the tag on landing pages built for ads.
add_filter( 'statsy_should_track', fn( $track ) => $track && ! is_page( 'lp' ) );
// Add or change attributes on the script tag.
add_filter( 'statsy_script_attributes', function ( $attrs ) {
$attrs['data-hash-routing'] = 'true';
return $attrs;
} );Without the plugin
If you would rather not add a plugin, paste the tag with a header scripts plugin such as WPCode, or into your child theme's header.php just before </head>.
<script defer data-website-id="ws_XXXXXXXX" data-domain="yourstartup.com" src="https://statsy.co/js/script.js"></script>Frequently asked questions
Is the plugin on WordPress.org?
Yes: wordpress.org/plugins/statsy-analytics. Search for Statsy Analytics under Plugins › Add New, and updates arrive with your other plugin updates.
Does it work with caching plugins?
Yes. The tag is in the page HTML, so it is cached with the page. Purge the cache once after installing so older cached pages get it too.
What happens when I delete the plugin?
Its settings are removed. Order notes and the visitor id stored on past orders stay, because they belong to your order history.
Last updated · Markdown version