Hit counter

A hit counter is the oldest thing on the web and still one of the nicest. This one shows your site’s lifetime hit count, and it is available on every plan.

Put an element wherever the number belongs:

<span class="tinylytics_hits"></span>

Then switch on Hit counter under Settings โ†’ Tracking โ†’ Widgets.

The tag itself does not matter โ€” a span, a strong, a div all work. The class is what the script looks for. Put several on one page and they all show the same lifetime total, since it is a site figure rather than a page one.

To show the views of one page instead, for example on an index that lists several posts, add data-path. That counter shows the total views of that path, whatever the unique views setting says.

<span class="tinylytics_hits" data-path="/the-path/to-your-post"></span>

Unique hits instead

On a paid plan, switch on Count unique views under Hit counter and the element shows unique hits rather than total hits, which is the more modest and arguably more interesting number. Legacy free accounts fall back to the total.

Styles

A plain number suits most footers. For something with more character, pick a Style under Hit counter and the counter draws itself as an airport board, a mileage odometer, a GeoCities-era counter, or a calculator display:

Style Looks like
Split-flap board Split-flap tiles that clatter into place, like a departures board
Odometer Digit wheels that roll up to the count
90s web counter Green LED digits in a grey bevel, zero-padded to six places
LCD display Seven-segment calculator digits, zero-padded to six places

Plain text is the default.

Split-flap board 48,213
Odometer 48,213
90s web counter 48,213
LCD display 48,213

Each style scrambles in once when the page loads and then sits still. On a single-page app it only scrambles again when the count changes. Visitors who have asked their system for reduced motion see the finished counter straight away. Screen readers hear the number once, not a row of tiles.

The styles are a separate file that the script loads only when a style is chosen, so plain counters download nothing extra.

Styling

The plain number inherits whatever type surrounds it. Tabular figures stop it jittering as the count grows, which is worth two lines of CSS:

.tinylytics_hits {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

The drawn styles are sized in em, so font-size on the element scales them. Three custom properties recolour them: --tinylytics-hits-bg for tiles and screens, --tinylytics-hits-fg for the digits, and --tinylytics-hits-accent for the flap hinge, the odometer wheels, the web frame, or the unlit lcd segments. With the 90s web counter style, this gives a red LED counter in a dark frame:

.tinylytics_hits {
  font-size: 1.5rem;
  --tinylytics-hits-fg: #ff3b30;
  --tinylytics-hits-accent: #3f3f46;
}