Easiest and most reliable would be powered minecarts. Just use a circuit with two 'passage' events - one switching a blocking roller off on an 'off' signal, another opening a door (and turning a forward-pushing roller on) on the next 'on' signal.
(cart moves from left to right)
╔╗ ╔╗
╚╚--╚╚--
╔╗ ╔╗
╚RrD╚RrD
* *
These are two counting cells, above only the paths, below the constructions.
R - roller pushing E->W, r - roller pushing W->E, D - door linked to input signal, * - gear linked to disengage on an off signal. One roller powers the other, because they're both 1x1, so they're on/off at the same time.
The R roller, when on, keeps the cart in the 2x2 loop. Once an 'off' signal is received, the rollers turn off and the door closes, the cart passes over 'R' and comes to rest on 'r', stopped by the door. Once the next 'on' signal arrives, the rollers turn back on and the door opens, letting the cart into the next counting cell. Add pressure plates to taste to keep track of where you are in the count, build it circular and send one signal per round to another counter cycle so you can count in multiples etc.
Very fast counters aren't really called for, because pressure plates can only send signals at least 100 steps apart (they'll only accept a new activation signal when the plate has reset and sent an 'off'); although this design, with a long enough primary counter loop, could also count lever activations sent on repeat, with periods down to 10 steps or so.
EDIT:
(cart moves counter-clockwise)
╔-╗╗ DRr╗
╔╗╚╝ ╔╗╚╝
╚╚-╝ ╚RrD
Free bonus - this is a binary counter. On each signal pair, the cart moves from one half of the circuit to the other. If you have a pressure plate in one half, you can use that as input for another binary counter. Ten of these can count to 1023.
EDIT2: I'm not sure how to proceed with a counting mechanism not held back by pressure plate delays. You could have a four-wide passage with four pressure plates and count them individually; just have some machine to add the results up somewhere down the line; this would at least avoid the problem of twenty dwarfs crawling over each other and only sending a single signal - this way, you'd get four, maybe even five signals!
You could try to build a sort of waterflow clock: traffic must pass through doors in a one-wide corridor. Above the door, there's a cistern with water (or lava, but that's not so useful for counting citizen traffic) and the tiles on top of the door are tunnelled out, so opening the door lets water flow down. The cistern would need to be regulated to a moderate water depth and should not be pressurised, or you won't get any actual traffic - everyone will be swept off their feet or cancels movement because of dangerous terrain. On both sides of the door, there'd be floor grates letting inflowing water through to another cistern below. Once the cistern there is full enough (measured by pressure plates, probably), it gets drained to a defined level and the counter advanced by one.
I've no idea if this'd be at all feasible. You'd measure amounts of water as a measurement of how long your doors remained open, although i'm not at all certain that the amount of water pouring through would be at all proportional to the length of time the door stayed open. Very fast or slow units would let wildly different amounts of water through anyway, and if anyone dropped an item or crushed a butterfly in the door, it'd remain open for a very, very long time. Not to mention that inflowing water could push units around and maybe even through the grates.
EDIT3: well, you could, by splitting up the traffic routes, spread out traffic enough that one passage would more or less mean one signal and count signals from pressure plates. You could even link all pressure plates to the same counting circuit, as long as the circuit was long enough - counting to 32 or so.
To further separate signals, you could use a 'borg logic' gate:
The bit in the south separates incoming/outgoing traffic into two one-way routes. If you put another hatch-over-a-pit right behind each pressure plate (in the example, only the northwestern plate could be configured like this, hatch would go north of the plate, connected to it), only one unit can pass at a time and the passage will only become available again when the signal has timed out and the pressure plate re-set, closing access hatch, crossing hatch and exit door.
It would not count passage of lightweight and trapavoiding units, but there'd be no counting them apart from waterflow tricks (cf. EDIT2; i have strong doubts if this'd really qualify as 'counting'). If a clump of units converged on a passage, followers can well get dumped down the hatch, with hilarious consequences.
So in sum - use logic gates to separate traffic into single passers, let them send signals via pressure plates, count signals with fluid/minecart/whatever logic (powered minecarts are very quick-reacting and accurate, so that's my recommendation). Problem theoretically solved. Do i get a cookie?