there is a little more to this I guess. stack overflow also checks unique people that visited. But for a basic solution I would create an table in the database with a simple int field. and set it to 0. (for every page)
Then create a PHP file where you would get this.
$pagid (Get url)
$result = mysql_query('Select count from counter WHERE pageid=$pagid');
$newcount = $result['count'] + 1;
mysql_query('UPDATE counter SET count=$newcount');
Then simply include this in every page and test if when you refresh the page the counter goes up. (The thing I declared in my code field above is a general rundown of what needs to happen so youll need to tweak it a bit)
When you get this to work you can go and try to add some checker if visitor is unique etc. But that is a problem of its own.
If u are ok with using PHP then add the PHP
tag the sessions
tag and the sql
tag, others may give you an better explanation than I did here.
Also the reason you would need to do this using PHP or other script is becouse twig the 'PHP' templated doesnt allow you to modify the database data. It only allows you to GET it.
Hope some of my explanation(s) made sense and hope this helps you with your problem!