Visitor counter for WordPress
On a self-hosted WordPress the counter goes into a Custom HTML block – in a post, on a page or in the footer widget area. The script works there as long as your user role may post unfiltered HTML, which administrators can.
Step by step
- Pick a design on Stats4U and copy the code from the HTML tab.
- In WordPress open the post, the page or Appearance → Widgets, click + and add a “Custom HTML” block.
- Paste the code into that block – not into a Paragraph block, which shows code as text instead of running it.
- Save or update, then open the published page.
The code
Tab for this platform: HTML
<script src="https://www.stats4u.net/s4u.js"
data-id="12345" data-style="3903" async></script>In this example the counter number is 12345 and the design is a sample. The wizard gives you your own number and the design you pick.
Good to know
- On the free WordPress.com plan, script, iframe and embed are removed from the Custom HTML block without any message. Use the HTML <img> or the Markdown tab there – a plain picture goes through on every plan.
- Without the unfiltered_html capability (an editor on a multisite network, for example) WordPress removes the script tag when saving. The HTML <img> tab works for every role.
Website insights
Measurements run only for features you enable. Saving disabled settings stops future collection.
Notes are private by default. Public notes are visible to everyone who can view the statistics.
Use short campaign labels without names, email addresses or customer IDs. Campaign values are limited; unrecognized values are ignored.
Choose two to eight steps. Use page:/contact or event:contact, one per line. Steps must occur in order within a visit; other activity may occur between them. A visit ends after thirty minutes of inactivity or at the day boundary. Reports count visits, not unique people.
Only action categories and names are counted. No phone numbers, email addresses or form field values are sent. A submitted form does not prove success. Confirm success with s4u.formSuccess('contact') or a supported WordPress form integration.
<form data-s4u-form="contact">…</form>
s4u.formSuccess('contact');Sales
Connect the shop using its counter number and shop secret. Report only confirmed payments and refunds. Net sales are paid amounts less refunds; counts of paid orders remain unchanged by refunds.
Stats4U shop
Enable shop reporting in your Stats4U owner link, create a shop secret and enter it here. Only confirmed payments and refunds are sent, with currency and an anonymous order reference. No customer details are sent.
Leave the secret blank to keep the existing one.
My dashboard
Choose which reports appear and in what order. Hidden cards are not loaded. The arrangement is private; readers use the standard arrangement.
Saved views
Save the current period and supported filters for another visit. Only the owner can see saved views. Relative periods move with the date; custom start and end dates stay fixed.
Page groups
Group related pages, for example /blog/* for the blog. The final * matches paths starting with that prefix. Up to ten groups with eight rules each are supported. Groups may overlap, so their visitor counts must not be added together.
Page views use available stored page totals and may include bots according to the counter setting. Group visitors and goals start being recorded when the group is created. Visitors count once per group per day, not once across the entire period.
Event properties
Define up to ten property names and up to twenty allowed values per property before sending them. Use fixed categories such as plan=basic, never names, email addresses, order numbers or form input. Each property is counted separately; combinations are not inferred.
At most five properties are accepted per event and 500 event/property/value combinations per counter/day.
Core Web Vitals
Measures loading (LCP), response to interactions (INP) and layout shifts (CLS) in supported browsers. Missing measurements are not zero. No INP is reported without interaction. Measurements start after enabling.
The 75th percentile is estimated from bounded histogram buckets. Up to 100 page/device combinations are retained per counter/day. Values at the last bucket mean at least that value. Browser measurements do not include all cross-origin iframe activity and are not identical to Google's CrUX data.
Enable optional Web Vitals measurement
Website statistics report
Choose a period and cards, then use your browser's print dialog to print or save a PDF. Owner-only notes are included only when opened with the owner key.
Dashboard and tools
Connect your own counter with its owner key. You can also paste the complete management link. Connected counters are remembered in this browser session; changing the owner key removes access.
Scheduled reports
Choose a saved view and weekly or monthly delivery to your confirmed owner email address. Filters and selected reports are reused; the report covers the previous complete week or month in the counter's timezone. Private notes are omitted. No mail is sent until you enable a schedule.
Embed a statistics card
Choose one report and its filters. The generated iframe uses a separate read-only key, expires on the selected date and can be revoked here. Private notes and owner actions are never included.
Statistics API
Create a separate read-only API key with selected reports. Send it as an Authorization: Bearer header; never use your owner key in scripts. API keys can be revoked and expire. JSON and CSV contain aggregate data only.
Exports cover at most 400 days and 500 rows per report. Counts of visitors and goal visitors are daily totals; overlapping groups must not be added together. Web Vitals percentiles use histogram estimates and require enough samples.
Guides for other platforms
- WixEmbed HTML in the Wix Editor or Embed Code in Wix Studio – and why Wix shows a different address in your statistics.
- BloggerThe HTML/JavaScript gadget puts the counter on every page of the blog.
- Google SitesInsert → Embed → Embed code in the new Google Sites.
- chomikuj.plThe profile description accepts pictures but no scripts – so the HTML <img> version goes in.
- GitHub PagesStraight into the HTML file or the Jekyll layout – Markdown pages work too.
- JimdoThe Widget/HTML element in Jimdo Creator – and why the newer Jimdo website builder has no place for it.
- WeeblyThe Embed Code element on one page, or the Footer Code field for every page of the site.
- NeocitiesInto the HTML of your page, with 88×31 buttons for your button wall.
- Forums & profilesBBCode for forum signatures and game profiles, HTML <img> where HTML is allowed.