Visitor counter
“You are visitor number 12,345.” Add a counter to any page with one line: no script, no cookies, and no counter service to sign up for. It's on every plan.
The quickest way to make one is the visitor counter maker: pick a look, see it, and copy the line.
Add one
Put this where the number should go, in any .html, .htm or .shtml page:
<p>You are visitor number <!--#counter --></p>
Visitors see You are visitor number 12,345. The number is plain text, so it takes your page's
styles. To style it, wrap it: <strong class="count"><!--#counter --></strong>.
The line is a Server Side Include, so it can also go in a shared footer that every page includes. The number is the same on every page.
What it counts
- People, once a day. Each visitor counts once a day, however many pages they open or how often they reload, the same way as your Analytics tab. Reloading doesn't push the number up.
- The whole site. A visit to any page counts, not only to pages with a counter.
- The reader included. A new visitor sees the number with themselves in it.
- Not robots. Search engines and other bots see the number but don't add to it.
- From the start of your site's analytics, so a counter added today shows the visitors you've already had, not 1.
Pages in a password-protected area count too. Previews in the editor show the number but aren't visits.
Moving from another counter
Had a counter on your old site? Start from its number with start, which is added to the count:
<!--#counter start="48210" -->
Digits in boxes
Add theme for the classic look. Here's each with the number 12,345:
<!--#counter theme="classic" --><!--#counter theme="odometer" --><!--#counter theme="led" --><!--#counter theme="led" color="lime" --><!--#counter theme="odometer" color="#f4e7c5" background="saddlebrown" font="serif" --><!--#counter theme="classic" color="navy" background="#e8eefc" border="steelblue" corners="rounded" separator="," -->
Then adjust it to match your site:
| Setting | Values | What it does |
|---|---|---|
theme | classic, odometer, led, none | The look. none is described below. |
digits | 1 to 12, normally 6 | How many boxes at least, filled with zeros in front: 012345. Bigger numbers get more boxes. |
color | a colour | The digits. |
background | a colour | The boxes. |
border | a colour, or none | The line around each box. |
size | small, medium, large, or 10 to 96 (pixels) | How big. medium, the normal size, matches the text around it. |
font | mono, serif, sans, inherit | inherit uses your site's font. |
corners | square, rounded | The boxes' corners. |
separator | one character, or none | Between groups of three digits. Off in themes; , in plain counters, where separator="" turns it off. |
start | 0 to 1,000,000,000 | Added to the count. |
Colours are written like #1a2b3c or #abc, or by
name, like navy or
goldenrod.
A setting the counter doesn't recognise, or a value it can't use, shows “[an error occurred while processing this directive]” instead of the counter, so a typo is easy to spot. The theme settings only work with a theme.
Your own digit images
Have a set of counter digits from the 90s, or want to draw your own? Put ten images in your site, named after
their digit (0.gif to 9.gif), and point the counter at them with * where
the digit goes:
<!--#counter images="/counter/*.gif" digits="6" -->
images takes the place of theme. size sets the images' height in pixels,
and digits and separator work as above. The path is in your site, starting from the
top folder with / or from the page without. Use images you made or have the right to use.
Styling it with your own CSS
theme="none" gives you the boxes with no styles at all, to style in your stylesheet:
.pagehaus-counter { display: inline-flex; gap: 2px; }
.pagehaus-counter-digit { background: #222; color: #ffd166; padding: 2px 4px; }
The class names are pagehaus-counter (around it all), pagehaus-counter-digit (each box
or image) and pagehaus-counter-separator. Themes use the same names, so you can adjust a theme in
your CSS too; add !important to change something the theme sets.
Screen readers read the number once, as “12,345”, not each box.
Previewing on your computer
pagehaus serve shows counters with a sample number, 1,234: the
real one is counted on your site. Update to version 0.2.0 or later; older versions show the error message where a
counter is. A browser opening the file straight from your computer shows nothing, as with any include.